Update builtins to use component command flag
This commit is contained in:
parent
5115bc3fb3
commit
bd9ba0654e
@ -1,7 +1,6 @@
|
|||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/DavidGamba/go-getoptions/option"
|
|
||||||
"github.com/hashicorp/vagrant-plugin-sdk/component"
|
"github.com/hashicorp/vagrant-plugin-sdk/component"
|
||||||
plugincore "github.com/hashicorp/vagrant-plugin-sdk/core"
|
plugincore "github.com/hashicorp/vagrant-plugin-sdk/core"
|
||||||
"github.com/hashicorp/vagrant-plugin-sdk/docs"
|
"github.com/hashicorp/vagrant-plugin-sdk/docs"
|
||||||
@ -99,13 +98,16 @@ func (c *Command) Help() string {
|
|||||||
return "I'm here for testing, try running some subcommands"
|
return "I'm here for testing, try running some subcommands"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Command) Flags() []*option.Option {
|
func (c *Command) Flags() component.CommandFlags {
|
||||||
stringflag := option.New("hehe", option.StringType)
|
return []*component.CommandFlag{
|
||||||
stringflag.Description = "a test flag for strings"
|
{
|
||||||
stringflag.DefaultStr = "message"
|
LongName: "hehe",
|
||||||
stringflag.Aliases = append(stringflag.Aliases, "hh")
|
ShortName: "",
|
||||||
|
Description: "a test flag for strings",
|
||||||
return []*option.Option{stringflag}
|
DefaultValue: "a default message",
|
||||||
|
Type: component.FlagString,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Command) Execute(trm terminal.UI, flags map[string]interface{}) int32 {
|
func (c *Command) Execute(trm terminal.UI, flags map[string]interface{}) int32 {
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/DavidGamba/go-getoptions/option"
|
|
||||||
"github.com/hashicorp/vagrant-plugin-sdk/component"
|
"github.com/hashicorp/vagrant-plugin-sdk/component"
|
||||||
"github.com/hashicorp/vagrant-plugin-sdk/docs"
|
"github.com/hashicorp/vagrant-plugin-sdk/docs"
|
||||||
"github.com/hashicorp/vagrant-plugin-sdk/terminal"
|
"github.com/hashicorp/vagrant-plugin-sdk/terminal"
|
||||||
@ -57,21 +56,26 @@ func (c *DoThing) Synopsis() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *DoThing) Help() string {
|
func (c *DoThing) Help() string {
|
||||||
return "I do really important work"
|
return "Usage: vagrant myplugin dothing"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *DoThing) Flags() []*option.Option {
|
func (c *DoThing) Flags() component.CommandFlags {
|
||||||
booltest := option.New("booltest", option.BoolType)
|
return []*component.CommandFlag{
|
||||||
booltest.Description = "a test flag for bools"
|
{
|
||||||
booltest.DefaultStr = "true"
|
LongName: "booltest",
|
||||||
booltest.Aliases = append(booltest.Aliases, "bt")
|
ShortName: "b",
|
||||||
|
Description: "test flag for bools",
|
||||||
stringflag := option.New("stringflag", option.StringType)
|
DefaultValue: "true",
|
||||||
stringflag.Description = "a test flag for strings"
|
Type: component.FlagBool,
|
||||||
stringflag.DefaultStr = "message"
|
},
|
||||||
stringflag.Aliases = append(stringflag.Aliases, "sf")
|
{
|
||||||
|
LongName: "stringflag",
|
||||||
return []*option.Option{booltest, stringflag}
|
ShortName: "s",
|
||||||
|
Description: "test flag for strings",
|
||||||
|
DefaultValue: "a default message value",
|
||||||
|
Type: component.FlagString,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *DoThing) Execute(trm terminal.UI, flags map[string]interface{}) int32 {
|
func (c *DoThing) Execute(trm terminal.UI, flags map[string]interface{}) int32 {
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/DavidGamba/go-getoptions/option"
|
|
||||||
"github.com/hashicorp/vagrant-plugin-sdk/component"
|
"github.com/hashicorp/vagrant-plugin-sdk/component"
|
||||||
"github.com/hashicorp/vagrant-plugin-sdk/core"
|
"github.com/hashicorp/vagrant-plugin-sdk/core"
|
||||||
"github.com/hashicorp/vagrant-plugin-sdk/terminal"
|
"github.com/hashicorp/vagrant-plugin-sdk/terminal"
|
||||||
@ -40,8 +39,8 @@ func (c *Host) Help() string {
|
|||||||
return c.Synopsis()
|
return c.Synopsis()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Host) Flags() []*option.Option {
|
func (c *Host) Flags() component.CommandFlags {
|
||||||
return []*option.Option{}
|
return []*component.CommandFlag{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Host) Execute(trm terminal.UI, project core.Project) int32 {
|
func (c *Host) Execute(trm terminal.UI, project core.Project) int32 {
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package command
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/DavidGamba/go-getoptions/option"
|
|
||||||
"github.com/hashicorp/vagrant-plugin-sdk/component"
|
"github.com/hashicorp/vagrant-plugin-sdk/component"
|
||||||
plugincore "github.com/hashicorp/vagrant-plugin-sdk/core"
|
plugincore "github.com/hashicorp/vagrant-plugin-sdk/core"
|
||||||
"github.com/hashicorp/vagrant-plugin-sdk/docs"
|
"github.com/hashicorp/vagrant-plugin-sdk/docs"
|
||||||
@ -63,8 +62,8 @@ func (c *Info) Help() string {
|
|||||||
return "Output some project information!"
|
return "Output some project information!"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Info) Flags() []*option.Option {
|
func (c *Info) Flags() component.CommandFlags {
|
||||||
return []*option.Option{}
|
return []*component.CommandFlag{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Info) Execute(trm terminal.UI, p plugincore.Project) int32 {
|
func (c *Info) Execute(trm terminal.UI, p plugincore.Project) int32 {
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/DavidGamba/go-getoptions/option"
|
|
||||||
"github.com/hashicorp/vagrant-plugin-sdk/component"
|
"github.com/hashicorp/vagrant-plugin-sdk/component"
|
||||||
"github.com/hashicorp/vagrant-plugin-sdk/docs"
|
"github.com/hashicorp/vagrant-plugin-sdk/docs"
|
||||||
"github.com/hashicorp/vagrant-plugin-sdk/terminal"
|
"github.com/hashicorp/vagrant-plugin-sdk/terminal"
|
||||||
@ -60,8 +59,8 @@ func (c *Interactive) Help() string {
|
|||||||
return "Test out interactive input!"
|
return "Test out interactive input!"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Interactive) Flags() []*option.Option {
|
func (c *Interactive) Flags() component.CommandFlags {
|
||||||
return []*option.Option{}
|
return []*component.CommandFlag{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Interactive) Execute(trm terminal.UI) int32 {
|
func (c *Interactive) Execute(trm terminal.UI) int32 {
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package otherplugin
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/DavidGamba/go-getoptions/option"
|
|
||||||
"github.com/hashicorp/vagrant-plugin-sdk/component"
|
"github.com/hashicorp/vagrant-plugin-sdk/component"
|
||||||
plugincore "github.com/hashicorp/vagrant-plugin-sdk/core"
|
plugincore "github.com/hashicorp/vagrant-plugin-sdk/core"
|
||||||
|
|
||||||
@ -45,12 +44,12 @@ func (c *Command) CommandInfo() *component.CommandInfo {
|
|||||||
Name: "otherplugin",
|
Name: "otherplugin",
|
||||||
Help: "HELP MEEEEE!",
|
Help: "HELP MEEEEE!",
|
||||||
Synopsis: "This command does stuff",
|
Synopsis: "This command does stuff",
|
||||||
Flags: []*option.Option{
|
Flags: []*component.CommandFlag{
|
||||||
&option.Option{
|
{
|
||||||
Name: "thing",
|
LongName: "thing",
|
||||||
OptType: option.StringType,
|
Description: "a thing flag",
|
||||||
Description: "a thing flag",
|
DefaultValue: "I'm a thing!",
|
||||||
DefaultStr: "I'm a thing!",
|
Type: component.FlagString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Subcommands: []*component.CommandInfo{
|
Subcommands: []*component.CommandInfo{
|
||||||
@ -58,13 +57,13 @@ func (c *Command) CommandInfo() *component.CommandInfo {
|
|||||||
Name: "info",
|
Name: "info",
|
||||||
Help: "Shows info",
|
Help: "Shows info",
|
||||||
Synopsis: "IT. SHOWS. INFO.",
|
Synopsis: "IT. SHOWS. INFO.",
|
||||||
Flags: []*option.Option{},
|
Flags: []*component.CommandFlag{},
|
||||||
Subcommands: []*component.CommandInfo{
|
Subcommands: []*component.CommandInfo{
|
||||||
&component.CommandInfo{
|
&component.CommandInfo{
|
||||||
Name: "ofni",
|
Name: "ofni",
|
||||||
Help: "Shows ofni",
|
Help: "Shows ofni",
|
||||||
Synopsis: "BIZZARO info",
|
Synopsis: "BIZZARO info",
|
||||||
Flags: []*option.Option{},
|
Flags: []*component.CommandFlag{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -72,12 +71,12 @@ func (c *Command) CommandInfo() *component.CommandInfo {
|
|||||||
Name: "dothing",
|
Name: "dothing",
|
||||||
Help: "Does thing",
|
Help: "Does thing",
|
||||||
Synopsis: "Does this super great thing!",
|
Synopsis: "Does this super great thing!",
|
||||||
Flags: []*option.Option{
|
Flags: []*component.CommandFlag{
|
||||||
&option.Option{
|
{
|
||||||
OptType: option.StringType,
|
LongName: "stringflag",
|
||||||
Name: "stringflag",
|
Description: "a test flag",
|
||||||
Description: "a test flag",
|
DefaultValue: "I'm a string!",
|
||||||
DefaultStr: "I'm a string!",
|
Type: component.FlagString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -85,7 +84,7 @@ func (c *Command) CommandInfo() *component.CommandInfo {
|
|||||||
Name: "use-host",
|
Name: "use-host",
|
||||||
Help: "Executes a host capability",
|
Help: "Executes a host capability",
|
||||||
Synopsis: "Executes a host capability",
|
Synopsis: "Executes a host capability",
|
||||||
Flags: []*option.Option{},
|
Flags: []*component.CommandFlag{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user