Execute subcommands
This commit is contained in:
parent
fb6842a3c0
commit
66300d9d32
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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(),
|
||||
|
||||
@ -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{},
|
||||
),
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user