Add command that tests executing host capabilities

This commit is contained in:
sophia 2021-04-28 17:06:47 -05:00 committed by Paul Hinze
parent e86dc5958a
commit 703458800c
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0

View File

@ -4,6 +4,7 @@ import (
"strings"
"github.com/DavidGamba/go-getoptions/option"
"github.com/hashicorp/go-argmapper"
"github.com/hashicorp/vagrant-plugin-sdk/component"
plugincore "github.com/hashicorp/vagrant-plugin-sdk/core"
// "github.com/hashicorp/vagrant-plugin-sdk/proto/vagrant_plugin_sdk"
@ -29,6 +30,8 @@ func (c *Command) ExecuteFunc(cliArgs []string) interface{} {
return c.ExecuteInfo
case "dothing":
return c.ExecuteThing
case "use-host":
return c.ExecuteUseHostPlugin
}
return c.ExecuteMain
}
@ -78,6 +81,12 @@ func (c *Command) CommandInfo() *component.CommandInfo {
},
},
},
&component.CommandInfo{
Name: "use-host",
Help: "Executes a host capability",
Synopsis: "Executes a host capability",
Flags: []*option.Option{},
},
},
}
}
@ -146,3 +155,11 @@ func (c *Command) ExecuteOfni(trm terminal.UI) int64 {
trm.Output("I am bizzaro info! Call me ofni")
return 0
}
func (c *Command) ExecuteUseHostPlugin(trm terminal.UI, host plugincore.Host) int64 {
trm.Output("I'm going to use a the host plugin to do something!")
if ok, _ := host.HasCapability("write_hello"); ok {
host.Capability("write_hello", argmapper.Typed(trm))
}
return 0
}