(userInput string)
| 132 | } |
| 133 | |
| 134 | func (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 { |
no test coverage detected