From 703458800ce8ca52a2b4a32d4b75732b616a349d Mon Sep 17 00:00:00 2001 From: sophia Date: Wed, 28 Apr 2021 17:06:47 -0500 Subject: [PATCH] Add command that tests executing host capabilities --- builtin/otherplugin/command.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/builtin/otherplugin/command.go b/builtin/otherplugin/command.go index d169a1a22..ee3fa2f82 100644 --- a/builtin/otherplugin/command.go +++ b/builtin/otherplugin/command.go @@ -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 +}