package main import ( "fmt" "github.com/spf13/cobra" "skillmgr/internal/installer" "skillmgr/internal/types" ) var uninstallCmd = &cobra.Command{ Use: "uninstall ", Short: "卸载 skill 或 command", Long: `卸载已安装的 skill 或 command。 类型: skill, command 示例: skillmgr uninstall skill lyxy-kb --platform claude --global skillmgr uninstall command lyxy-kb --platform opencode`, Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { itemType := args[0] name := args[1] platformStr, _ := cmd.Flags().GetString("platform") global, _ := cmd.Flags().GetBool("global") platform := types.Platform(platformStr) scope := types.ScopeProject if global { scope = types.ScopeGlobal } switch itemType { case "skill": return installer.UninstallSkill(name, platform, scope) case "command": return installer.UninstallCommand(name, platform, scope) default: return fmt.Errorf("无效的类型: %s(必须是 'skill' 或 'command')", itemType) } }, } func init() { uninstallCmd.Flags().StringP("platform", "p", "", "目标平台 (claude|opencode)") uninstallCmd.Flags().BoolP("global", "g", false, "全局卸载") uninstallCmd.MarkFlagRequired("platform") rootCmd.AddCommand(uninstallCmd) }