HandleCommand routes /skill subcommands.
(ctx context.Context, userInput string)
| 67 | |
| 68 | // HandleCommand routes /skill subcommands. |
| 69 | func (sh *SkillHandler) HandleCommand(ctx context.Context, userInput string) { |
| 70 | if sh.registryMgr == nil { |
| 71 | fmt.Println(colorize(" "+i18n.T("skill.registry.not_initialized"), ColorYellow)) |
| 72 | if sh.initErr != nil { |
| 73 | fmt.Printf(" %s: %s\n", i18n.T("skill.error"), sh.initErr.Error()) |
| 74 | } |
| 75 | return |
| 76 | } |
| 77 | |
| 78 | args := strings.Fields(userInput) |
| 79 | if len(args) < 2 { |
| 80 | sh.ShowHelp() |
| 81 | return |
| 82 | } |
| 83 | |
| 84 | subcommand := strings.ToLower(args[1]) |
| 85 | |
| 86 | switch subcommand { |
| 87 | case "search": |
| 88 | if len(args) < 3 { |
| 89 | fmt.Println(colorize(" "+i18n.T("skill.usage.search"), ColorYellow)) |
| 90 | return |
| 91 | } |
| 92 | query := strings.Join(args[2:], " ") |
| 93 | sh.Search(ctx, query) |
| 94 | |
| 95 | case "install": |
| 96 | if len(args) < 3 { |
| 97 | fmt.Println(colorize(" "+i18n.T("skill.usage.install"), ColorYellow)) |
| 98 | return |
| 99 | } |
| 100 | // Parse optional --from <registry> flag |
| 101 | skillName, fromRegistry := parseInstallArgs(args[2:]) |
| 102 | if skillName == "" { |
| 103 | fmt.Println(colorize(" "+i18n.T("skill.usage.install"), ColorYellow)) |
| 104 | return |
| 105 | } |
| 106 | sh.Install(ctx, skillName, fromRegistry) |
| 107 | |
| 108 | case "uninstall", "remove": |
| 109 | if len(args) < 3 { |
| 110 | fmt.Println(colorize(" "+i18n.T("skill.usage.uninstall"), ColorYellow)) |
| 111 | return |
| 112 | } |
| 113 | sh.Uninstall(args[2]) |
| 114 | |
| 115 | case "list", "ls": |
| 116 | sh.List() |
| 117 | |
| 118 | case "registries", "registry": |
| 119 | if len(args) >= 4 { |
| 120 | action := strings.ToLower(args[2]) |
| 121 | regName := args[3] |
| 122 | switch action { |
| 123 | case "enable": |
| 124 | sh.SetRegistryEnabled(regName, true) |
| 125 | return |
| 126 | case "disable": |