diff --git a/builtin/myplugin/commands/command.go b/builtin/myplugin/commands/command.go index f038f26bd..b797f1cbd 100644 --- a/builtin/myplugin/commands/command.go +++ b/builtin/myplugin/commands/command.go @@ -79,6 +79,10 @@ func (c *Command) Subcommands() []*plugincore.CommandInfo { func (c *Command) Execute(trm terminal.UI) int64 { trm.Output(c.Help()) + trm.Output("My subcommands are: ") + for _, cmd := range c.Subcommands() { + trm.Output(" " + cmd.Name) + } return 0 } diff --git a/builtin/myplugin/commands/dothing.go b/builtin/myplugin/commands/dothing.go index d99a89cd8..2145fb50a 100644 --- a/builtin/myplugin/commands/dothing.go +++ b/builtin/myplugin/commands/dothing.go @@ -46,7 +46,7 @@ func (c *DoThing) CommandInfoFunc() interface{} { func (c *DoThing) CommandInfo() *plugincore.CommandInfo { return &plugincore.CommandInfo{ - Name: "donothing", + Name: "dothing", Help: c.Help(), Synopsis: c.Synopsis(), Flags: c.Flags(), diff --git a/builtin/myplugin/main.go b/builtin/myplugin/main.go index abe785b7b..09851f0c8 100644 --- a/builtin/myplugin/main.go +++ b/builtin/myplugin/main.go @@ -8,9 +8,23 @@ import ( //go:generate protoc -I ../../.. --go_opt=plugins=grpc --go_out=../../.. vagrant-ruby/builtin/myplugin/plugin.proto // Options are the SDK options to use for instantiation. -var Options = []sdk.Option{ +var CommandOptions = []sdk.Option{ sdk.WithComponents( &Provider{}, &commands.Command{}, ), } + +var InfoOptions = []sdk.Option{ + sdk.WithComponents( + &Provider{}, + &commands.Info{}, + ), +} + +var DoThingOptions = []sdk.Option{ + sdk.WithComponents( + &Provider{}, + &commands.DoThing{}, + ), +} diff --git a/internal/core/project.go b/internal/core/project.go index 6628de62f..396ed8eaf 100644 --- a/internal/core/project.go +++ b/internal/core/project.go @@ -3,7 +3,6 @@ package core import ( "context" "io" - "strings" "sync" "github.com/golang/protobuf/proto" @@ -200,8 +199,8 @@ func (p *Project) specializeComponent(c *Component) (cmp plugin.PluginMetadata, func (p *Project) Run(ctx context.Context, task *vagrant_server.Task) (err error) { p.logger.Debug("running new task", "project", p, "task", task) - componentName := strings.Split(task.Component.Name, " ")[0] - cmd, err := p.basis.component(ctx, component.CommandType, componentName) + // componentName := strings.Split(task.Component.Name, " ")[0] + cmd, err := p.basis.component(ctx, component.CommandType, task.Component.Name) if err != nil { return err } diff --git a/internal/plugin/plugin.go b/internal/plugin/plugin.go index 78a84c66d..0eb2cdaf8 100644 --- a/internal/plugin/plugin.go +++ b/internal/plugin/plugin.go @@ -14,7 +14,9 @@ var ( // Builtins is the map of all available builtin plugins and their // options for launching them. Builtins = map[string][]sdk.Option{ - "myplugin": myplugin.Options, + "myplugin": myplugin.CommandOptions, + "myplugin dothing": myplugin.DoThingOptions, + "myplugin info": myplugin.InfoOptions, } // Rubies is a map of all available plugins accessible via the