From 7cc9ab9083070c20dba75b1362cfadb7df45a7d9 Mon Sep 17 00:00:00 2001 From: Felix Frank Date: Tue, 12 Nov 2019 01:47:26 +0100 Subject: [PATCH 1/2] lib: Update for urfave/cli v2 --- lang/gapi.go | 28 +++---- langpuppet/gapi.go | 16 ++-- lib/cli.go | 184 ++++++++++++++++++++++----------------------- lib/deploy.go | 2 +- lib/get.go | 2 +- lib/run.go | 2 +- puppet/gapi.go | 6 +- yamlgraph/gapi.go | 4 +- 8 files changed, 122 insertions(+), 122 deletions(-) diff --git a/lang/gapi.go b/lang/gapi.go index f481a8ccdb..30d7537e42 100644 --- a/lang/gapi.go +++ b/lang/gapi.go @@ -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", }, @@ -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)", @@ -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", //}, @@ -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") } @@ -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... @@ -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") } diff --git a/langpuppet/gapi.go b/langpuppet/gapi.go index d0b80a3967..58624a02b7 100644 --- a/langpuppet/gapi.go +++ b/langpuppet/gapi.go @@ -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", @@ -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]), }) } @@ -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? @@ -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, diff --git a/lib/cli.go b/lib/cli.go index ecdeb4257f..9ef5721945 100644 --- a/lib/cli.go +++ b/lib/cli.go @@ -41,155 +41,155 @@ func CLI(program, version string, flags Flags) error { } // All of these flags can be accessed in your GAPI implementation with - // the `c.Parent().Type` and `c.Parent().IsSet` functions. Their own + // the `c.Lineage()[1].Type` and `c.Lineage()[1].IsSet` functions. Their own // flags can be accessed with `c.Type` and `c.IsSet` directly. runFlags := []cli.Flag{ // common flags which all can use // useful for testing multiple instances on same machine - cli.StringFlag{ + &cli.StringFlag{ Name: "hostname", Value: "", Usage: "hostname to use", }, - cli.StringFlag{ - Name: "prefix", - Usage: "specify a path to the working prefix directory", - EnvVar: "MGMT_PREFIX", + &cli.StringFlag{ + Name: "prefix", + Usage: "specify a path to the working prefix directory", + EnvVars: []string{"MGMT_PREFIX"}, }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "tmp-prefix", Usage: "request a pseudo-random, temporary prefix to be used", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "allow-tmp-prefix", Usage: "allow creation of a new temporary prefix if main prefix is unavailable", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "no-watch", Usage: "do not update graph under any switch events", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "no-stream-watch", Usage: "do not update graph on stream switch events", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "no-deploy-watch", Usage: "do not change deploys after an initial deploy", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "noop", Usage: "globally force all resources into no-op mode", }, - cli.IntFlag{ + &cli.IntFlag{ Name: "sema", Value: -1, Usage: "globally add a semaphore to all resources with this lock count", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "graphviz, g", Value: "", Usage: "output file for graphviz data", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "graphviz-filter, gf", Value: "", Usage: "graphviz filter to use", }, - cli.Int64Flag{ - Name: "converged-timeout, t", - Value: -1, - Usage: "after approximately this many seconds without activity, we're considered to be in a converged state", - EnvVar: "MGMT_CONVERGED_TIMEOUT", + &cli.Int64Flag{ + Name: "converged-timeout, t", + Value: -1, + Usage: "after approximately this many seconds without activity, we're considered to be in a converged state", + EnvVars: []string{"MGMT_CONVERGED_TIMEOUT"}, }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "converged-timeout-no-exit", Usage: "don't exit on converged-timeout", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "converged-status-file", Value: "", Usage: "file to append the current converged state to, mostly used for testing", }, - cli.IntFlag{ - Name: "max-runtime", - Value: 0, - Usage: "exit after a maximum of approximately this many seconds", - EnvVar: "MGMT_MAX_RUNTIME", + &cli.IntFlag{ + Name: "max-runtime", + Value: 0, + Usage: "exit after a maximum of approximately this many seconds", + EnvVars: []string{"MGMT_MAX_RUNTIME"}, }, // if empty, it will startup a new server - cli.StringSliceFlag{ - Name: "seeds, s", - Value: &cli.StringSlice{}, // empty slice - Usage: "default etc client endpoint", - EnvVar: "MGMT_SEEDS", + &cli.StringSliceFlag{ + Name: "seeds, s", + Value: &cli.StringSlice{}, // empty slice + Usage: "default etc client endpoint", + EnvVars: []string{"MGMT_SEEDS"}, }, // port 2379 and 4001 are common - cli.StringSliceFlag{ - Name: "client-urls", - Value: &cli.StringSlice{}, - Usage: "list of URLs to listen on for client traffic", - EnvVar: "MGMT_CLIENT_URLS", + &cli.StringSliceFlag{ + Name: "client-urls", + Value: &cli.StringSlice{}, + Usage: "list of URLs to listen on for client traffic", + EnvVars: []string{"MGMT_CLIENT_URLS"}, }, // port 2380 and 7001 are common - cli.StringSliceFlag{ - Name: "server-urls, peer-urls", - Value: &cli.StringSlice{}, - Usage: "list of URLs to listen on for server (peer) traffic", - EnvVar: "MGMT_SERVER_URLS", + &cli.StringSliceFlag{ + Name: "server-urls, peer-urls", + Value: &cli.StringSlice{}, + Usage: "list of URLs to listen on for server (peer) traffic", + EnvVars: []string{"MGMT_SERVER_URLS"}, }, // port 2379 and 4001 are common - cli.StringSliceFlag{ - Name: "advertise-client-urls", - Value: &cli.StringSlice{}, - Usage: "list of URLs to listen on for client traffic", - EnvVar: "MGMT_ADVERTISE_CLIENT_URLS", + &cli.StringSliceFlag{ + Name: "advertise-client-urls", + Value: &cli.StringSlice{}, + Usage: "list of URLs to listen on for client traffic", + EnvVars: []string{"MGMT_ADVERTISE_CLIENT_URLS"}, }, // port 2380 and 7001 are common - cli.StringSliceFlag{ - Name: "advertise-server-urls, advertise-peer-urls", - Value: &cli.StringSlice{}, - Usage: "list of URLs to listen on for server (peer) traffic", - EnvVar: "MGMT_ADVERTISE_SERVER_URLS", - }, - cli.IntFlag{ - Name: "ideal-cluster-size", - Value: -1, - Usage: "ideal number of server peers in cluster; only read by initial server", - EnvVar: "MGMT_IDEAL_CLUSTER_SIZE", - }, - cli.BoolFlag{ + &cli.StringSliceFlag{ + Name: "advertise-server-urls, advertise-peer-urls", + Value: &cli.StringSlice{}, + Usage: "list of URLs to listen on for server (peer) traffic", + EnvVars: []string{"MGMT_ADVERTISE_SERVER_URLS"}, + }, + &cli.IntFlag{ + Name: "ideal-cluster-size", + Value: -1, + Usage: "ideal number of server peers in cluster; only read by initial server", + EnvVars: []string{"MGMT_IDEAL_CLUSTER_SIZE"}, + }, + &cli.BoolFlag{ Name: "no-server", Usage: "do not start embedded etcd server (do not promote from client to peer)", }, - cli.BoolFlag{ - Name: "no-network", - Usage: "run single node instance without clustering or opening tcp ports to the outside", - EnvVar: "MGMT_NO_NETWORK", + &cli.BoolFlag{ + Name: "no-network", + Usage: "run single node instance without clustering or opening tcp ports to the outside", + EnvVars: []string{"MGMT_NO_NETWORK"}, }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "no-pgp", Usage: "don't create pgp keys", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "pgp-key-path", Value: "", Usage: "path for instance key pair", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "pgp-identity", Value: "", Usage: "default identity used for generation", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "prometheus", Usage: "start a prometheus instance", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "prometheus-listen", Value: "", Usage: "specify prometheus instance binding", @@ -197,51 +197,51 @@ func CLI(program, version string, flags Flags) error { } deployFlags := []cli.Flag{ // common flags which all can use - cli.StringSliceFlag{ - Name: "seeds, s", - Value: &cli.StringSlice{}, // empty slice - Usage: "default etc client endpoint", - EnvVar: "MGMT_SEEDS", + &cli.StringSliceFlag{ + Name: "seeds, s", + Value: &cli.StringSlice{}, // empty slice + Usage: "default etc client endpoint", + EnvVars: []string{"MGMT_SEEDS"}, }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "noop", Usage: "globally force all resources into no-op mode", }, - cli.IntFlag{ + &cli.IntFlag{ Name: "sema", Value: -1, Usage: "globally add a semaphore to all resources with this lock count", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "no-git", Usage: "don't look at git commit id for safe deploys", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "force", Usage: "force a new deploy, even if the safety chain would break", }, } getFlags := []cli.Flag{ // common flags which all can use - cli.BoolFlag{ + &cli.BoolFlag{ Name: "noop", Usage: "simulate the download (can't recurse)", }, - cli.IntFlag{ + &cli.IntFlag{ Name: "sema", Value: -1, // maximum parallelism Usage: "globally add a semaphore to downloads with this lock count", }, - cli.BoolFlag{ + &cli.BoolFlag{ Name: "update", Usage: "update all dependencies to the latest versions", }, } - subCommandsRun := []cli.Command{} // run sub commands - subCommandsDeploy := []cli.Command{} // deploy sub commands - subCommandsGet := []cli.Command{} // get (download) sub commands + subCommandsRun := []*cli.Command{} // run sub commands + subCommandsDeploy := []*cli.Command{} // deploy sub commands + subCommandsGet := []*cli.Command{} // get (download) sub commands names := []string{} for name := range gapi.RegisteredGAPIs { @@ -253,7 +253,7 @@ func CLI(program, version string, flags Flags) error { fn := gapi.RegisteredGAPIs[name] gapiObj := fn() - commandRun := cli.Command{ + commandRun := &cli.Command{ Name: name, Usage: fmt.Sprintf("run using the `%s` frontend", name), Action: func(c *cli.Context) error { @@ -268,7 +268,7 @@ func CLI(program, version string, flags Flags) error { } subCommandsRun = append(subCommandsRun, commandRun) - commandDeploy := cli.Command{ + commandDeploy := &cli.Command{ Name: name, Usage: fmt.Sprintf("deploy using the `%s` frontend", name), Action: func(c *cli.Context) error { @@ -284,7 +284,7 @@ func CLI(program, version string, flags Flags) error { subCommandsDeploy = append(subCommandsDeploy, commandDeploy) if _, ok := gapiObj.(gapi.GettableGAPI); ok { - commandGet := cli.Command{ + commandGet := &cli.Command{ Name: name, Usage: fmt.Sprintf("get (download) using the `%s` frontend", name), Action: func(c *cli.Context) error { @@ -329,13 +329,13 @@ func CLI(program, version string, flags Flags) error { // global flags app.Flags = []cli.Flag{ - cli.BoolFlag{ + &cli.BoolFlag{ Name: "license", Usage: "prints the software license", }, } - app.Commands = []cli.Command{ + app.Commands = []*cli.Command{ //{ // Name: gapi.CommandTODO, // Aliases: []string{"TODO"}, @@ -350,7 +350,7 @@ func CLI(program, version string, flags Flags) error { // agnostic to which frontend is running, in fact, you can deploy with // multiple different frontends, one after another, on the same engine. if len(subCommandsRun) > 0 { - commandRun := cli.Command{ + commandRun := &cli.Command{ Name: gapi.CommandRun, Aliases: []string{"r"}, Usage: "run", @@ -361,7 +361,7 @@ func CLI(program, version string, flags Flags) error { } if len(subCommandsDeploy) > 0 { - commandDeploy := cli.Command{ + commandDeploy := &cli.Command{ Name: gapi.CommandDeploy, Aliases: []string{"d"}, Usage: "deploy", @@ -372,7 +372,7 @@ func CLI(program, version string, flags Flags) error { } if len(subCommandsGet) > 0 { - commandGet := cli.Command{ + commandGet := &cli.Command{ Name: gapi.CommandGet, Aliases: []string{"g"}, Usage: "get", diff --git a/lib/deploy.go b/lib/deploy.go index a2871baa46..a5914ad22c 100644 --- a/lib/deploy.go +++ b/lib/deploy.go @@ -44,7 +44,7 @@ const ( // deploy is the cli target to manage deploys to our cluster. // TODO: add a timeout and/or cancel signal to replace context.TODO() func deploy(c *cli.Context, name string, gapiObj gapi.GAPI) error { - cliContext := c.Parent() + cliContext := c.Lineage()[1] if cliContext == nil { return fmt.Errorf("could not get cli context") } diff --git a/lib/get.go b/lib/get.go index f9ed1f8eb7..6e2973d62c 100644 --- a/lib/get.go +++ b/lib/get.go @@ -28,7 +28,7 @@ import ( // get is the cli target to run code/import downloads. func get(c *cli.Context, name string, gapiObj gapi.GAPI) error { - cliContext := c.Parent() + cliContext := c.Lineage()[1] if cliContext == nil { return fmt.Errorf("could not get cli context") } diff --git a/lib/run.go b/lib/run.go index 48704a9dcc..3095cdbe3c 100644 --- a/lib/run.go +++ b/lib/run.go @@ -35,7 +35,7 @@ import ( // run is the main run target. func run(c *cli.Context, name string, gapiObj gapi.GAPI) error { - cliContext := c.Parent() // these are the flags from `run` + cliContext := c.Lineage()[1] // these are the flags from `run` if cliContext == nil { return fmt.Errorf("could not get cli context") } diff --git a/puppet/gapi.go b/puppet/gapi.go index ce8d5664a7..ba020c12b0 100644 --- a/puppet/gapi.go +++ b/puppet/gapi.go @@ -70,7 +70,7 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag { fallthrough case gapi.CommandDeploy: return []cli.Flag{ - cli.StringFlag{ + &cli.StringFlag{ Name: "puppet-conf", Value: "", Usage: "the path to an alternate puppet.conf file", @@ -157,8 +157,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(), Mode: mode, diff --git a/yamlgraph/gapi.go b/yamlgraph/gapi.go index 081873363e..326abd3726 100644 --- a/yamlgraph/gapi.go +++ b/yamlgraph/gapi.go @@ -93,8 +93,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... From 33d89c27397c4f94beb0d381fbdd0b2ccd0c5c28 Mon Sep 17 00:00:00 2001 From: Felix Frank Date: Tue, 12 Nov 2019 20:50:14 +0100 Subject: [PATCH 2/2] examples: lib: Update code for urfave/cli v2 --- examples/lib/exec-send-recv.go | 6 +++--- examples/lib/libmgmt-subgraph0.go | 6 +++--- examples/lib/libmgmt-subgraph1.go | 6 +++--- examples/lib/libmgmt2.go | 6 +++--- examples/lib/libmgmt3.go | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/lib/exec-send-recv.go b/examples/lib/exec-send-recv.go index 93f4d37cc8..3e5b99b928 100644 --- a/examples/lib/exec-send-recv.go +++ b/examples/lib/exec-send-recv.go @@ -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", @@ -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 } diff --git a/examples/lib/libmgmt-subgraph0.go b/examples/lib/libmgmt-subgraph0.go index fdd7476ffb..e413dad070 100644 --- a/examples/lib/libmgmt-subgraph0.go +++ b/examples/lib/libmgmt-subgraph0.go @@ -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", @@ -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 } diff --git a/examples/lib/libmgmt-subgraph1.go b/examples/lib/libmgmt-subgraph1.go index e59d0fabf6..a06ff92f56 100644 --- a/examples/lib/libmgmt-subgraph1.go +++ b/examples/lib/libmgmt-subgraph1.go @@ -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", @@ -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 } diff --git a/examples/lib/libmgmt2.go b/examples/lib/libmgmt2.go index 596e79e9fc..60b2501bd4 100644 --- a/examples/lib/libmgmt2.go +++ b/examples/lib/libmgmt2.go @@ -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", @@ -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 } diff --git a/examples/lib/libmgmt3.go b/examples/lib/libmgmt3.go index d0439ad69d..74ab254c9c 100644 --- a/examples/lib/libmgmt3.go +++ b/examples/lib/libmgmt3.go @@ -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", @@ -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 }