Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Urfave cli v2 #571

Merged
merged 2 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/lib/exec-send-recv.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewMyGAPI(data *gapi.Data, name string, interval uint) (*MyGAPI, error) {
// CliFlags returns a list of flags used by the passed in subcommand.
func (obj *MyGAPI) CliFlags(string) []cli.Flag {
return []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: obj.Name,
Value: "",
Usage: "run",
Expand All @@ -69,8 +69,8 @@ func (obj *MyGAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {

return &gapi.Deploy{
Name: obj.Name,
Noop: c.GlobalBool("noop"),
Sema: c.GlobalInt("sema"),
Noop: c.Bool("noop"),
Sema: c.Int("sema"),
GAPI: &MyGAPI{},
}, nil
}
Expand Down
6 changes: 3 additions & 3 deletions examples/lib/libmgmt-subgraph0.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewMyGAPI(data *gapi.Data, name string, interval uint) (*MyGAPI, error) {
// CliFlags returns a list of flags used by the passed in subcommand.
func (obj *MyGAPI) CliFlags(string) []cli.Flag {
return []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: obj.Name,
Value: "",
Usage: "run",
Expand All @@ -74,8 +74,8 @@ func (obj *MyGAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {

return &gapi.Deploy{
Name: obj.Name,
Noop: c.GlobalBool("noop"),
Sema: c.GlobalInt("sema"),
Noop: c.Bool("noop"),
Sema: c.Int("sema"),
GAPI: &MyGAPI{},
}, nil
}
Expand Down
6 changes: 3 additions & 3 deletions examples/lib/libmgmt-subgraph1.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewMyGAPI(data *gapi.Data, name string, interval uint) (*MyGAPI, error) {
// CliFlags returns a list of flags used by the passed in subcommand.
func (obj *MyGAPI) CliFlags(string) []cli.Flag {
return []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: obj.Name,
Value: "",
Usage: "run",
Expand All @@ -69,8 +69,8 @@ func (obj *MyGAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {

return &gapi.Deploy{
Name: obj.Name,
Noop: c.GlobalBool("noop"),
Sema: c.GlobalInt("sema"),
Noop: c.Bool("noop"),
Sema: c.Int("sema"),
GAPI: &MyGAPI{},
}, nil
}
Expand Down
6 changes: 3 additions & 3 deletions examples/lib/libmgmt2.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewMyGAPI(data *gapi.Data, name string, interval uint, count uint) (*MyGAPI
// CliFlags returns a list of flags used by the passed in subcommand.
func (obj *MyGAPI) CliFlags(string) []cli.Flag {
return []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: obj.Name,
Value: "",
Usage: "run",
Expand All @@ -71,8 +71,8 @@ func (obj *MyGAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {

return &gapi.Deploy{
Name: obj.Name,
Noop: c.GlobalBool("noop"),
Sema: c.GlobalInt("sema"),
Noop: c.Bool("noop"),
Sema: c.Int("sema"),
GAPI: &MyGAPI{},
}, nil
}
Expand Down
6 changes: 3 additions & 3 deletions examples/lib/libmgmt3.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewMyGAPI(data *gapi.Data, name string, interval uint) (*MyGAPI, error) {
// CliFlags returns a list of flags used by the passed in subcommand.
func (obj *MyGAPI) CliFlags(string) []cli.Flag {
return []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: obj.Name,
Value: "",
Usage: "run",
Expand All @@ -69,8 +69,8 @@ func (obj *MyGAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {

return &gapi.Deploy{
Name: obj.Name,
Noop: c.GlobalBool("noop"),
Sema: c.GlobalInt("sema"),
Noop: c.Bool("noop"),
Sema: c.Int("sema"),
GAPI: &MyGAPI{},
}, nil
}
Expand Down
28 changes: 14 additions & 14 deletions lang/gapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,21 @@ type GAPI struct {
// CliFlags returns a list of flags used by the specified subcommand.
func (obj *GAPI) CliFlags(command string) []cli.Flag {
result := []cli.Flag{}
modulePath := cli.StringFlag{
Name: flagModulePath,
Value: "", // empty by default
Usage: "choose the modules path (absolute)",
EnvVar: "MGMT_MODULE_PATH",
modulePath := &cli.StringFlag{
Name: flagModulePath,
Value: "", // empty by default
Usage: "choose the modules path (absolute)",
EnvVars: []string{"MGMT_MODULE_PATH"},
}

// add this only to run (not needed for get or deploy)
if command == gapi.CommandRun {
runFlags := []cli.Flag{
cli.BoolFlag{
&cli.BoolFlag{
Name: flagDownload,
Usage: "download any missing imports (as the get command does)",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "update",
Usage: "update all dependencies to the latest versions",
},
Expand All @@ -91,12 +91,12 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag {
switch command {
case gapi.CommandGet:
flags := []cli.Flag{
cli.IntFlag{
&cli.IntFlag{
Name: "depth d",
Value: -1,
Usage: "max recursion depth limit (-1 is unlimited)",
},
cli.IntFlag{
&cli.IntFlag{
Name: "retry r",
Value: 0, // any error is a failure by default
Usage: "max number of retries (-1 is unlimited)",
Expand All @@ -110,7 +110,7 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag {
case gapi.CommandDeploy:
flags := []cli.Flag{
// TODO: removed (temporarily?)
//cli.BoolFlag{
//*cli.BoolFlag{
// Name: "stdin",
// Usage: "use passthrough stdin",
//},
Expand Down Expand Up @@ -140,7 +140,7 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag {
// is passed in.
func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {
c := cliInfo.CliContext
cliContext := c.Parent()
cliContext := c.Lineage()[1]
if cliContext == nil {
return nil, fmt.Errorf("could not get cli context")
}
Expand Down Expand Up @@ -397,8 +397,8 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {

return &gapi.Deploy{
Name: Name,
Noop: c.GlobalBool("noop"),
Sema: c.GlobalInt("sema"),
Noop: c.Bool("noop"),
Sema: c.Int("sema"),
GAPI: &GAPI{
InputURI: fs.URI(),
// TODO: add properties here...
Expand Down Expand Up @@ -611,7 +611,7 @@ func (obj *GAPI) Close() error {
// also work when called with the download flag during a normal execution run.
func (obj *GAPI) Get(getInfo *gapi.GetInfo) error {
c := getInfo.CliContext
cliContext := c.Parent()
cliContext := c.Lineage()[1]
if cliContext == nil {
return fmt.Errorf("could not get cli context")
}
Expand Down
16 changes: 8 additions & 8 deletions langpuppet/gapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag {
langFlags := (&lang.GAPI{}).CliFlags(command)
puppetFlags := (&puppet.GAPI{}).CliFlags(command)

l := cli.StringFlag{
l := &cli.StringFlag{
Name: fmt.Sprintf("%s, %s", lang.Name, lang.Name[0:1]),
Value: "",
Usage: "code to deploy",
}
langFlags = append(langFlags, l)
p := cli.StringFlag{
p := &cli.StringFlag{
Name: fmt.Sprintf("%s, %s", puppet.Name, puppet.Name[0:1]),
Value: "",
Usage: "load graph from puppet, optionally takes a manifest or path to manifest file",
Expand All @@ -89,9 +89,9 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag {
var childFlags []cli.Flag
for _, flag := range append(langFlags, puppetFlags...) {
childFlags = append(childFlags, &cli.StringFlag{
Name: FlagPrefix + strings.Split(flag.GetName(), ",")[0],
Name: FlagPrefix + flag.Names()[0],
Value: "",
Usage: fmt.Sprintf("equivalent for '%s' when using the lang/puppet entrypoint", flag.GetName()),
Usage: fmt.Sprintf("equivalent for '%s' when using the lang/puppet entrypoint", flag.Names()[0]),
})
}

Expand Down Expand Up @@ -136,14 +136,14 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {
var puppetDeploy *gapi.Deploy
// XXX: put the c.String(FlagPrefix+lang.Name) into the argv here!
langCliInfo := &gapi.CliInfo{
CliContext: cli.NewContext(c.App, flagSet, c.Parent()),
CliContext: cli.NewContext(c.App, flagSet, c.Lineage()[1]),
Fs: fs,
Debug: debug,
Logf: logf, // TODO: wrap logf?
}
// XXX: put the c.String(FlagPrefix+puppet.Name) into the argv here!
puppetCliInfo := &gapi.CliInfo{
CliContext: cli.NewContext(c.App, flagSet, c.Parent()),
CliContext: cli.NewContext(c.App, flagSet, c.Lineage()[1]),
Fs: fs,
Debug: debug,
Logf: logf, // TODO: wrap logf?
Expand All @@ -160,8 +160,8 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {

return &gapi.Deploy{
Name: Name,
Noop: c.GlobalBool("noop"),
Sema: c.GlobalInt("sema"),
Noop: c.Bool("noop"),
Sema: c.Int("sema"),
GAPI: &GAPI{
langGAPI: langDeploy.GAPI,
puppetGAPI: puppetDeploy.GAPI,
Expand Down
Loading