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) }