MCPcopy Create free account
hub / github.com/diillson/chatcli / handlePluginCommand

Method handlePluginCommand

cli/command_handler_plugins.go:134–209  ·  view source on GitHub ↗
(userInput string)

Source from the content-addressed store, hash-verified

132}
133
134func (ch *CommandHandler) handlePluginCommand(userInput string) {
135 if ch.cli.pluginManager == nil {
136 ch.cli.logger.Error("O gerenciador de plugins não está inicializado. O comando /plugin está desabilitado.")
137 fmt.Println(i18n.T("plugin.error.manager_disabled"))
138 return
139 }
140
141 args := strings.Fields(userInput)
142 if len(args) < 2 {
143 fmt.Println(i18n.T("plugin.usage_header"))
144 return
145 }
146
147 subcommand := args[1]
148 pluginManager := ch.cli.pluginManager
149
150 switch subcommand {
151 case "list":
152 plugins := pluginManager.GetPlugins()
153 if len(plugins) == 0 {
154 fmt.Println(i18n.T("plugin.list.empty"))
155 return
156 }
157 fmt.Println(i18n.T("plugin.list.header"))
158 for _, p := range plugins {
159 fmt.Printf(" %s %s - %s\n", colorize(p.Name(), ColorCyan), colorize(p.Version(), ColorGray), p.Description())
160 }
161
162 case "show":
163 if len(args) < 3 {
164 fmt.Println(i18n.T("plugin.show.usage"))
165 return
166 }
167 p, found := pluginManager.GetPlugin(args[2])
168 if !found {
169 fmt.Println(i18n.T("plugin.error.not_found", args[2]))
170 return
171 }
172 fmt.Println(i18n.T("plugin.show.details_for", p.Name()))
173 fmt.Printf(" %s: %s\n", colorize(i18n.T("plugin.show.description"), ColorCyan), p.Description())
174 fmt.Printf(" %s: %s\n", colorize(i18n.T("plugin.show.usage_label"), ColorCyan), p.Usage())
175 fmt.Printf(" %s: %s\n", colorize(i18n.T("plugin.show.version"), ColorCyan), p.Version())
176
177 case "inspect":
178 if len(args) < 3 {
179 fmt.Println(i18n.T("plugin.inspect.usage"))
180 return
181 }
182 p, found := pluginManager.GetPlugin(args[2])
183 if !found {
184 fmt.Println(i18n.T("plugin.error.not_found", args[2]))
185 return
186 }
187 fmt.Println(i18n.T("plugin.inspect.details_for", p.Name()))
188 fmt.Printf(" %s: %s\n", colorize(i18n.T("plugin.inspect.path"), ColorCyan), p.Path())
189 if info, err := os.Stat(p.Path()); err == nil {
190 fmt.Printf(" %s: %s\n", colorize(i18n.T("plugin.inspect.permissions"), ColorCyan), info.Mode().String())
191 } else {

Callers 1

buildRoutesMethod · 0.95

Calls 15

pluginInstallMethod · 0.95
pluginUninstallMethod · 0.95
TFunction · 0.92
colorizeFunction · 0.85
GetPluginMethod · 0.80
ErrorMethod · 0.65
NameMethod · 0.65
VersionMethod · 0.65
DescriptionMethod · 0.65
UsageMethod · 0.65
PathMethod · 0.65
ModeMethod · 0.65

Tested by

no test coverage detected