()
| 253 | } |
| 254 | |
| 255 | func newPluginInstallCmd() *cobra.Command { |
| 256 | var file string |
| 257 | var location string |
| 258 | |
| 259 | cmd := &cobra.Command{ |
| 260 | Use: "install", |
| 261 | Short: "Install a plugin", |
| 262 | Long: "Install a plugin to the plugins directory from a specified URL or local file.", |
| 263 | RunE: func(cmd *cobra.Command, _ []string) error { |
| 264 | ctx := cmd.Context() |
| 265 | |
| 266 | opts := &action.PluginInstallOptions{ |
| 267 | File: file, |
| 268 | Location: location, |
| 269 | } |
| 270 | |
| 271 | result, err := action.NewPluginInstall(ActionOpts, pluginManager).Run(ctx, opts) |
| 272 | if err != nil { |
| 273 | return fmt.Errorf("failed to install plugin: %w", err) |
| 274 | } |
| 275 | |
| 276 | fmt.Printf("Plugin installed successfully to: %s\n", result.FilePath) |
| 277 | return nil |
| 278 | }, |
| 279 | } |
| 280 | |
| 281 | // Common flags |
| 282 | cmd.Flags().StringVarP(&file, "file", "f", "", "URL or path to the plugin to install") |
| 283 | cobra.CheckErr(cmd.MarkFlagRequired("file")) |
| 284 | |
| 285 | return cmd |
| 286 | } |
| 287 | |
| 288 | // findCommand recursively searches for a command by name in the command tree |
| 289 | func findCommand(rootCmd *cobra.Command, name string) *cobra.Command { |
no test coverage detected