wrote source code

This commit is contained in:
2026-05-02 00:19:07 +02:00
parent ef7a4a8c45
commit 1dd20f169f
5 changed files with 93 additions and 8 deletions
+38
View File
@@ -0,0 +1,38 @@
package cmd
import (
"fmt"
"os"
"os/exec"
"github.com/spf13/cobra"
)
// uninstallCmd represents the uninstall command
var uninstallCmd = &cobra.Command{
Use: "uninstall",
Short: "uninstalls a package",
Long: `Uninstalls a package.`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
fmt.Fprintln(os.Stderr, "error: package name required")
return
}
pkg := args[0]
// Ensure running as root (pacman requires root)
fmt.Println("uninstalling:", pkg)
out := exec.Command("sudo", "pacman", "-R", pkg)
out.Stdin =os.Stdin
out.Stdout =os.Stdout
out.Stderr =os.Stderr
out.Run()
fmt.Println("uninstall successful")
},
}
func init() {
rootCmd.AddCommand(uninstallCmd)
}