From 8ae73e2f61b5ff4f16a538059c6a71c2593c5fcb Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Tue, 5 Mar 2024 10:51:28 -0500 Subject: [PATCH] commands: introduce plugin as alias to plugins --- command/plugin.go | 32 ++++++++++++++++++++++++++++++++ commands.go | 26 ++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 command/plugin.go diff --git a/command/plugin.go b/command/plugin.go new file mode 100644 index 00000000000..722f0a9a9c3 --- /dev/null +++ b/command/plugin.go @@ -0,0 +1,32 @@ +package command + +import ( + "strings" + + "github.com/mitchellh/cli" +) + +type PluginCommand struct { + Meta +} + +func (c *PluginCommand) Synopsis() string { + return "Alias to `packer plugins` - Interact with Packer plugins and catalog" +} + +func (c *PluginCommand) Help() string { + helpText := ` +Usage: packer plugin [options] [args] + This command groups subcommands for interacting with Packer plugins. + +Related but not under the "plugin" command : + +- "packer init " will install all plugins required by a config. +` + + return strings.TrimSpace(helpText) +} + +func (c *PluginCommand) Run(args []string) int { + return cli.RunResultHelp +} diff --git a/commands.go b/commands.go index d7bd02b1d26..673c50cd739 100644 --- a/commands.go +++ b/commands.go @@ -65,30 +65,56 @@ func init() { }, nil }, + "plugin": func() (cli.Command, error) { + return &command.PluginCommand{ + Meta: *CommandMeta, + }, nil + }, + "plugins": func() (cli.Command, error) { return &command.PluginsCommand{ Meta: *CommandMeta, }, nil }, + "plugin installed": func() (cli.Command, error) { + return &command.PluginsInstalledCommand{ + Meta: *CommandMeta, + }, nil + }, "plugins installed": func() (cli.Command, error) { return &command.PluginsInstalledCommand{ Meta: *CommandMeta, }, nil }, + "plugin install": func() (cli.Command, error) { + return &command.PluginsInstallCommand{ + Meta: *CommandMeta, + }, nil + }, "plugins install": func() (cli.Command, error) { return &command.PluginsInstallCommand{ Meta: *CommandMeta, }, nil }, + "plugin remove": func() (cli.Command, error) { + return &command.PluginsRemoveCommand{ + Meta: *CommandMeta, + }, nil + }, "plugins remove": func() (cli.Command, error) { return &command.PluginsRemoveCommand{ Meta: *CommandMeta, }, nil }, + "plugin required": func() (cli.Command, error) { + return &command.PluginsRequiredCommand{ + Meta: *CommandMeta, + }, nil + }, "plugins required": func() (cli.Command, error) { return &command.PluginsRequiredCommand{ Meta: *CommandMeta,