feat(plugin): Add option to update plugin (#1462)

* Add option to update plugin

- add plugin update [pluginName] to update
- add supporting test

* refactor: wrap errors
This commit is contained in:
Owen Rumney
2021-12-16 11:30:19 +00:00
committed by GitHub
parent 1e811de263
commit 8bfbc84a41
4 changed files with 98 additions and 3 deletions

View File

@@ -686,6 +686,12 @@ func NewPluginCommand() *cli.Command {
ArgsUsage: "PLUGIN_NAME [PLUGIN_OPTIONS]",
Action: plugin.Run,
},
{
Name: "update",
Usage: "update an existing plugin",
ArgsUsage: "PLUGIN_NAME",
Action: plugin.Update,
},
},
}
}

View File

@@ -90,6 +90,24 @@ func List(c *cli.Context) error {
return nil
}
// Update updates an existing plugin
func Update(c *cli.Context) error {
if c.NArg() != 1 {
cli.ShowSubcommandHelpAndExit(c, 1)
}
if err := initLogger(c); err != nil {
return xerrors.Errorf("initialize error: %w", err)
}
pluginName := c.Args().First()
if err := plugin.Update(pluginName); err != nil {
return xerrors.Errorf("plugin update error: %w", err)
}
return nil
}
// Run runs the plugin
func Run(c *cli.Context) error {
if c.NArg() < 1 {