1
0
Files
Skill/manager/cmd/skillmgr/uninstall.go

54 lines
1.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import (
"fmt"
"github.com/spf13/cobra"
"skillmgr/internal/installer"
"skillmgr/internal/types"
)
var uninstallCmd = &cobra.Command{
Use: "uninstall <type> <name>",
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)
}