Update to use component command flags
This commit is contained in:
parent
3933632216
commit
5115bc3fb3
@ -1,7 +1,7 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"github.com/DavidGamba/go-getoptions"
|
||||
"github.com/hashicorp/vagrant-plugin-sdk/component"
|
||||
"github.com/hashicorp/vagrant-plugin-sdk/terminal"
|
||||
)
|
||||
|
||||
@ -18,7 +18,7 @@ func WithArgs(args []string) Option {
|
||||
// WithFlags sets the flags that are supported by this command. This MUST
|
||||
// be set otherwise a panic will happen. This is usually set by just calling
|
||||
// the Flags function on your command implementation.
|
||||
func WithFlags(f *getoptions.GetOpt) Option {
|
||||
func WithFlags(f []*component.CommandFlag) Option {
|
||||
return func(c *baseConfig) { c.Flags = f }
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ func WithUI(ui terminal.UI) Option {
|
||||
|
||||
type baseConfig struct {
|
||||
Args []string
|
||||
Flags *getoptions.GetOpt
|
||||
Flags component.CommandFlags
|
||||
Config bool
|
||||
ConfigOptional bool
|
||||
Client bool
|
||||
|
||||
@ -5,11 +5,12 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/DavidGamba/go-getoptions"
|
||||
"github.com/skratchdot/open-golang/open"
|
||||
|
||||
"github.com/hashicorp/vagrant-plugin-sdk/component"
|
||||
"github.com/hashicorp/vagrant-plugin-sdk/terminal"
|
||||
"github.com/hashicorp/vagrant/internal/clierrors"
|
||||
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
|
||||
"github.com/skratchdot/open-golang/open"
|
||||
)
|
||||
|
||||
type UICommand struct {
|
||||
@ -86,14 +87,14 @@ func (c *UICommand) Run(args []string) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (c *UICommand) Flags() *getoptions.GetOpt {
|
||||
return c.flagSet(0, func(set *getoptions.GetOpt) {
|
||||
|
||||
set.BoolVar(
|
||||
&c.flagAuthenticate,
|
||||
"authenticate",
|
||||
false,
|
||||
set.Description("Creates a new invite token and passes it to the UI for authorization"),
|
||||
func (c *UICommand) Flags() component.CommandFlags {
|
||||
return c.flagSet(0, func(set []*component.CommandFlag) []*component.CommandFlag {
|
||||
return append(set,
|
||||
&component.CommandFlag{
|
||||
LongName: "authenticate",
|
||||
Description: "Creates a new invite token and passes it to the UI for authorization",
|
||||
DefaultValue: "false",
|
||||
},
|
||||
)
|
||||
})
|
||||
}
|
||||
@ -117,5 +118,5 @@ Usage: vagrant ui [options]
|
||||
Opens the new UI. When provided a flag, will automatically open the
|
||||
token invite page with an invite token for authentication.
|
||||
|
||||
` + c.Flags().Help())
|
||||
` + c.Flags().Display())
|
||||
}
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"github.com/DavidGamba/go-getoptions"
|
||||
|
||||
"github.com/hashicorp/vagrant-plugin-sdk/component"
|
||||
"github.com/hashicorp/vagrant/internal/version"
|
||||
)
|
||||
|
||||
@ -31,7 +30,7 @@ func (c *VersionCommand) Run(args []string) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (c *VersionCommand) Flags() *getoptions.GetOpt {
|
||||
func (c *VersionCommand) Flags() component.CommandFlags {
|
||||
return c.flagSet(0, nil)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user