lib: Update for urfave/cli v2

This commit is contained in:
Felix Frank
2019-11-12 01:47:26 +01:00
parent 4b4b7dc169
commit 7cc9ab9083
8 changed files with 120 additions and 120 deletions

View File

@@ -66,21 +66,21 @@ type GAPI struct {
// CliFlags returns a list of flags used by the specified subcommand. // CliFlags returns a list of flags used by the specified subcommand.
func (obj *GAPI) CliFlags(command string) []cli.Flag { func (obj *GAPI) CliFlags(command string) []cli.Flag {
result := []cli.Flag{} result := []cli.Flag{}
modulePath := cli.StringFlag{ modulePath := &cli.StringFlag{
Name: flagModulePath, Name: flagModulePath,
Value: "", // empty by default Value: "", // empty by default
Usage: "choose the modules path (absolute)", Usage: "choose the modules path (absolute)",
EnvVar: "MGMT_MODULE_PATH", EnvVars: []string{"MGMT_MODULE_PATH"},
} }
// add this only to run (not needed for get or deploy) // add this only to run (not needed for get or deploy)
if command == gapi.CommandRun { if command == gapi.CommandRun {
runFlags := []cli.Flag{ runFlags := []cli.Flag{
cli.BoolFlag{ &cli.BoolFlag{
Name: flagDownload, Name: flagDownload,
Usage: "download any missing imports (as the get command does)", Usage: "download any missing imports (as the get command does)",
}, },
cli.BoolFlag{ &cli.BoolFlag{
Name: "update", Name: "update",
Usage: "update all dependencies to the latest versions", Usage: "update all dependencies to the latest versions",
}, },
@@ -91,12 +91,12 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag {
switch command { switch command {
case gapi.CommandGet: case gapi.CommandGet:
flags := []cli.Flag{ flags := []cli.Flag{
cli.IntFlag{ &cli.IntFlag{
Name: "depth d", Name: "depth d",
Value: -1, Value: -1,
Usage: "max recursion depth limit (-1 is unlimited)", Usage: "max recursion depth limit (-1 is unlimited)",
}, },
cli.IntFlag{ &cli.IntFlag{
Name: "retry r", Name: "retry r",
Value: 0, // any error is a failure by default Value: 0, // any error is a failure by default
Usage: "max number of retries (-1 is unlimited)", Usage: "max number of retries (-1 is unlimited)",
@@ -110,7 +110,7 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag {
case gapi.CommandDeploy: case gapi.CommandDeploy:
flags := []cli.Flag{ flags := []cli.Flag{
// TODO: removed (temporarily?) // TODO: removed (temporarily?)
//cli.BoolFlag{ //*cli.BoolFlag{
// Name: "stdin", // Name: "stdin",
// Usage: "use passthrough stdin", // Usage: "use passthrough stdin",
//}, //},
@@ -140,7 +140,7 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag {
// is passed in. // is passed in.
func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) { func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {
c := cliInfo.CliContext c := cliInfo.CliContext
cliContext := c.Parent() cliContext := c.Lineage()[1]
if cliContext == nil { if cliContext == nil {
return nil, fmt.Errorf("could not get cli context") 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{ return &gapi.Deploy{
Name: Name, Name: Name,
Noop: c.GlobalBool("noop"), Noop: c.Bool("noop"),
Sema: c.GlobalInt("sema"), Sema: c.Int("sema"),
GAPI: &GAPI{ GAPI: &GAPI{
InputURI: fs.URI(), InputURI: fs.URI(),
// TODO: add properties here... // 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. // also work when called with the download flag during a normal execution run.
func (obj *GAPI) Get(getInfo *gapi.GetInfo) error { func (obj *GAPI) Get(getInfo *gapi.GetInfo) error {
c := getInfo.CliContext c := getInfo.CliContext
cliContext := c.Parent() cliContext := c.Lineage()[1]
if cliContext == nil { if cliContext == nil {
return fmt.Errorf("could not get cli context") return fmt.Errorf("could not get cli context")
} }

View File

@@ -73,13 +73,13 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag {
langFlags := (&lang.GAPI{}).CliFlags(command) langFlags := (&lang.GAPI{}).CliFlags(command)
puppetFlags := (&puppet.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]), Name: fmt.Sprintf("%s, %s", lang.Name, lang.Name[0:1]),
Value: "", Value: "",
Usage: "code to deploy", Usage: "code to deploy",
} }
langFlags = append(langFlags, l) langFlags = append(langFlags, l)
p := cli.StringFlag{ p := &cli.StringFlag{
Name: fmt.Sprintf("%s, %s", puppet.Name, puppet.Name[0:1]), Name: fmt.Sprintf("%s, %s", puppet.Name, puppet.Name[0:1]),
Value: "", Value: "",
Usage: "load graph from puppet, optionally takes a manifest or path to manifest file", 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 var childFlags []cli.Flag
for _, flag := range append(langFlags, puppetFlags...) { for _, flag := range append(langFlags, puppetFlags...) {
childFlags = append(childFlags, &cli.StringFlag{ childFlags = append(childFlags, &cli.StringFlag{
Name: FlagPrefix + strings.Split(flag.GetName(), ",")[0], Name: FlagPrefix + flag.Names()[0],
Value: "", 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 var puppetDeploy *gapi.Deploy
// XXX: put the c.String(FlagPrefix+lang.Name) into the argv here! // XXX: put the c.String(FlagPrefix+lang.Name) into the argv here!
langCliInfo := &gapi.CliInfo{ langCliInfo := &gapi.CliInfo{
CliContext: cli.NewContext(c.App, flagSet, c.Parent()), CliContext: cli.NewContext(c.App, flagSet, c.Lineage()[1]),
Fs: fs, Fs: fs,
Debug: debug, Debug: debug,
Logf: logf, // TODO: wrap logf? Logf: logf, // TODO: wrap logf?
} }
// XXX: put the c.String(FlagPrefix+puppet.Name) into the argv here! // XXX: put the c.String(FlagPrefix+puppet.Name) into the argv here!
puppetCliInfo := &gapi.CliInfo{ puppetCliInfo := &gapi.CliInfo{
CliContext: cli.NewContext(c.App, flagSet, c.Parent()), CliContext: cli.NewContext(c.App, flagSet, c.Lineage()[1]),
Fs: fs, Fs: fs,
Debug: debug, Debug: debug,
Logf: logf, // TODO: wrap logf? Logf: logf, // TODO: wrap logf?
@@ -160,8 +160,8 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {
return &gapi.Deploy{ return &gapi.Deploy{
Name: Name, Name: Name,
Noop: c.GlobalBool("noop"), Noop: c.Bool("noop"),
Sema: c.GlobalInt("sema"), Sema: c.Int("sema"),
GAPI: &GAPI{ GAPI: &GAPI{
langGAPI: langDeploy.GAPI, langGAPI: langDeploy.GAPI,
puppetGAPI: puppetDeploy.GAPI, puppetGAPI: puppetDeploy.GAPI,

View File

@@ -41,155 +41,155 @@ func CLI(program, version string, flags Flags) error {
} }
// All of these flags can be accessed in your GAPI implementation with // 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. // flags can be accessed with `c.Type` and `c.IsSet` directly.
runFlags := []cli.Flag{ runFlags := []cli.Flag{
// common flags which all can use // common flags which all can use
// useful for testing multiple instances on same machine // useful for testing multiple instances on same machine
cli.StringFlag{ &cli.StringFlag{
Name: "hostname", Name: "hostname",
Value: "", Value: "",
Usage: "hostname to use", Usage: "hostname to use",
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "prefix", Name: "prefix",
Usage: "specify a path to the working prefix directory", Usage: "specify a path to the working prefix directory",
EnvVar: "MGMT_PREFIX", EnvVars: []string{"MGMT_PREFIX"},
}, },
cli.BoolFlag{ &cli.BoolFlag{
Name: "tmp-prefix", Name: "tmp-prefix",
Usage: "request a pseudo-random, temporary prefix to be used", Usage: "request a pseudo-random, temporary prefix to be used",
}, },
cli.BoolFlag{ &cli.BoolFlag{
Name: "allow-tmp-prefix", Name: "allow-tmp-prefix",
Usage: "allow creation of a new temporary prefix if main prefix is unavailable", Usage: "allow creation of a new temporary prefix if main prefix is unavailable",
}, },
cli.BoolFlag{ &cli.BoolFlag{
Name: "no-watch", Name: "no-watch",
Usage: "do not update graph under any switch events", Usage: "do not update graph under any switch events",
}, },
cli.BoolFlag{ &cli.BoolFlag{
Name: "no-stream-watch", Name: "no-stream-watch",
Usage: "do not update graph on stream switch events", Usage: "do not update graph on stream switch events",
}, },
cli.BoolFlag{ &cli.BoolFlag{
Name: "no-deploy-watch", Name: "no-deploy-watch",
Usage: "do not change deploys after an initial deploy", Usage: "do not change deploys after an initial deploy",
}, },
cli.BoolFlag{ &cli.BoolFlag{
Name: "noop", Name: "noop",
Usage: "globally force all resources into no-op mode", Usage: "globally force all resources into no-op mode",
}, },
cli.IntFlag{ &cli.IntFlag{
Name: "sema", Name: "sema",
Value: -1, Value: -1,
Usage: "globally add a semaphore to all resources with this lock count", Usage: "globally add a semaphore to all resources with this lock count",
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "graphviz, g", Name: "graphviz, g",
Value: "", Value: "",
Usage: "output file for graphviz data", Usage: "output file for graphviz data",
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "graphviz-filter, gf", Name: "graphviz-filter, gf",
Value: "", Value: "",
Usage: "graphviz filter to use", Usage: "graphviz filter to use",
}, },
cli.Int64Flag{ &cli.Int64Flag{
Name: "converged-timeout, t", Name: "converged-timeout, t",
Value: -1, Value: -1,
Usage: "after approximately this many seconds without activity, we're considered to be in a converged state", Usage: "after approximately this many seconds without activity, we're considered to be in a converged state",
EnvVar: "MGMT_CONVERGED_TIMEOUT", EnvVars: []string{"MGMT_CONVERGED_TIMEOUT"},
}, },
cli.BoolFlag{ &cli.BoolFlag{
Name: "converged-timeout-no-exit", Name: "converged-timeout-no-exit",
Usage: "don't exit on converged-timeout", Usage: "don't exit on converged-timeout",
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "converged-status-file", Name: "converged-status-file",
Value: "", Value: "",
Usage: "file to append the current converged state to, mostly used for testing", Usage: "file to append the current converged state to, mostly used for testing",
}, },
cli.IntFlag{ &cli.IntFlag{
Name: "max-runtime", Name: "max-runtime",
Value: 0, Value: 0,
Usage: "exit after a maximum of approximately this many seconds", Usage: "exit after a maximum of approximately this many seconds",
EnvVar: "MGMT_MAX_RUNTIME", EnvVars: []string{"MGMT_MAX_RUNTIME"},
}, },
// if empty, it will startup a new server // if empty, it will startup a new server
cli.StringSliceFlag{ &cli.StringSliceFlag{
Name: "seeds, s", Name: "seeds, s",
Value: &cli.StringSlice{}, // empty slice Value: &cli.StringSlice{}, // empty slice
Usage: "default etc client endpoint", Usage: "default etc client endpoint",
EnvVar: "MGMT_SEEDS", EnvVars: []string{"MGMT_SEEDS"},
}, },
// port 2379 and 4001 are common // port 2379 and 4001 are common
cli.StringSliceFlag{ &cli.StringSliceFlag{
Name: "client-urls", Name: "client-urls",
Value: &cli.StringSlice{}, Value: &cli.StringSlice{},
Usage: "list of URLs to listen on for client traffic", Usage: "list of URLs to listen on for client traffic",
EnvVar: "MGMT_CLIENT_URLS", EnvVars: []string{"MGMT_CLIENT_URLS"},
}, },
// port 2380 and 7001 are common // port 2380 and 7001 are common
cli.StringSliceFlag{ &cli.StringSliceFlag{
Name: "server-urls, peer-urls", Name: "server-urls, peer-urls",
Value: &cli.StringSlice{}, Value: &cli.StringSlice{},
Usage: "list of URLs to listen on for server (peer) traffic", Usage: "list of URLs to listen on for server (peer) traffic",
EnvVar: "MGMT_SERVER_URLS", EnvVars: []string{"MGMT_SERVER_URLS"},
}, },
// port 2379 and 4001 are common // port 2379 and 4001 are common
cli.StringSliceFlag{ &cli.StringSliceFlag{
Name: "advertise-client-urls", Name: "advertise-client-urls",
Value: &cli.StringSlice{}, Value: &cli.StringSlice{},
Usage: "list of URLs to listen on for client traffic", Usage: "list of URLs to listen on for client traffic",
EnvVar: "MGMT_ADVERTISE_CLIENT_URLS", EnvVars: []string{"MGMT_ADVERTISE_CLIENT_URLS"},
}, },
// port 2380 and 7001 are common // port 2380 and 7001 are common
cli.StringSliceFlag{ &cli.StringSliceFlag{
Name: "advertise-server-urls, advertise-peer-urls", Name: "advertise-server-urls, advertise-peer-urls",
Value: &cli.StringSlice{}, Value: &cli.StringSlice{},
Usage: "list of URLs to listen on for server (peer) traffic", Usage: "list of URLs to listen on for server (peer) traffic",
EnvVar: "MGMT_ADVERTISE_SERVER_URLS", EnvVars: []string{"MGMT_ADVERTISE_SERVER_URLS"},
}, },
cli.IntFlag{ &cli.IntFlag{
Name: "ideal-cluster-size", Name: "ideal-cluster-size",
Value: -1, Value: -1,
Usage: "ideal number of server peers in cluster; only read by initial server", Usage: "ideal number of server peers in cluster; only read by initial server",
EnvVar: "MGMT_IDEAL_CLUSTER_SIZE", EnvVars: []string{"MGMT_IDEAL_CLUSTER_SIZE"},
}, },
cli.BoolFlag{ &cli.BoolFlag{
Name: "no-server", Name: "no-server",
Usage: "do not start embedded etcd server (do not promote from client to peer)", Usage: "do not start embedded etcd server (do not promote from client to peer)",
}, },
cli.BoolFlag{ &cli.BoolFlag{
Name: "no-network", Name: "no-network",
Usage: "run single node instance without clustering or opening tcp ports to the outside", Usage: "run single node instance without clustering or opening tcp ports to the outside",
EnvVar: "MGMT_NO_NETWORK", EnvVars: []string{"MGMT_NO_NETWORK"},
}, },
cli.BoolFlag{ &cli.BoolFlag{
Name: "no-pgp", Name: "no-pgp",
Usage: "don't create pgp keys", Usage: "don't create pgp keys",
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "pgp-key-path", Name: "pgp-key-path",
Value: "", Value: "",
Usage: "path for instance key pair", Usage: "path for instance key pair",
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "pgp-identity", Name: "pgp-identity",
Value: "", Value: "",
Usage: "default identity used for generation", Usage: "default identity used for generation",
}, },
cli.BoolFlag{ &cli.BoolFlag{
Name: "prometheus", Name: "prometheus",
Usage: "start a prometheus instance", Usage: "start a prometheus instance",
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "prometheus-listen", Name: "prometheus-listen",
Value: "", Value: "",
Usage: "specify prometheus instance binding", Usage: "specify prometheus instance binding",
@@ -197,51 +197,51 @@ func CLI(program, version string, flags Flags) error {
} }
deployFlags := []cli.Flag{ deployFlags := []cli.Flag{
// common flags which all can use // common flags which all can use
cli.StringSliceFlag{ &cli.StringSliceFlag{
Name: "seeds, s", Name: "seeds, s",
Value: &cli.StringSlice{}, // empty slice Value: &cli.StringSlice{}, // empty slice
Usage: "default etc client endpoint", Usage: "default etc client endpoint",
EnvVar: "MGMT_SEEDS", EnvVars: []string{"MGMT_SEEDS"},
}, },
cli.BoolFlag{ &cli.BoolFlag{
Name: "noop", Name: "noop",
Usage: "globally force all resources into no-op mode", Usage: "globally force all resources into no-op mode",
}, },
cli.IntFlag{ &cli.IntFlag{
Name: "sema", Name: "sema",
Value: -1, Value: -1,
Usage: "globally add a semaphore to all resources with this lock count", Usage: "globally add a semaphore to all resources with this lock count",
}, },
cli.BoolFlag{ &cli.BoolFlag{
Name: "no-git", Name: "no-git",
Usage: "don't look at git commit id for safe deploys", Usage: "don't look at git commit id for safe deploys",
}, },
cli.BoolFlag{ &cli.BoolFlag{
Name: "force", Name: "force",
Usage: "force a new deploy, even if the safety chain would break", Usage: "force a new deploy, even if the safety chain would break",
}, },
} }
getFlags := []cli.Flag{ getFlags := []cli.Flag{
// common flags which all can use // common flags which all can use
cli.BoolFlag{ &cli.BoolFlag{
Name: "noop", Name: "noop",
Usage: "simulate the download (can't recurse)", Usage: "simulate the download (can't recurse)",
}, },
cli.IntFlag{ &cli.IntFlag{
Name: "sema", Name: "sema",
Value: -1, // maximum parallelism Value: -1, // maximum parallelism
Usage: "globally add a semaphore to downloads with this lock count", Usage: "globally add a semaphore to downloads with this lock count",
}, },
cli.BoolFlag{ &cli.BoolFlag{
Name: "update", Name: "update",
Usage: "update all dependencies to the latest versions", Usage: "update all dependencies to the latest versions",
}, },
} }
subCommandsRun := []cli.Command{} // run sub commands subCommandsRun := []*cli.Command{} // run sub commands
subCommandsDeploy := []cli.Command{} // deploy sub commands subCommandsDeploy := []*cli.Command{} // deploy sub commands
subCommandsGet := []cli.Command{} // get (download) sub commands subCommandsGet := []*cli.Command{} // get (download) sub commands
names := []string{} names := []string{}
for name := range gapi.RegisteredGAPIs { for name := range gapi.RegisteredGAPIs {
@@ -253,7 +253,7 @@ func CLI(program, version string, flags Flags) error {
fn := gapi.RegisteredGAPIs[name] fn := gapi.RegisteredGAPIs[name]
gapiObj := fn() gapiObj := fn()
commandRun := cli.Command{ commandRun := &cli.Command{
Name: name, Name: name,
Usage: fmt.Sprintf("run using the `%s` frontend", name), Usage: fmt.Sprintf("run using the `%s` frontend", name),
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
@@ -268,7 +268,7 @@ func CLI(program, version string, flags Flags) error {
} }
subCommandsRun = append(subCommandsRun, commandRun) subCommandsRun = append(subCommandsRun, commandRun)
commandDeploy := cli.Command{ commandDeploy := &cli.Command{
Name: name, Name: name,
Usage: fmt.Sprintf("deploy using the `%s` frontend", name), Usage: fmt.Sprintf("deploy using the `%s` frontend", name),
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
@@ -284,7 +284,7 @@ func CLI(program, version string, flags Flags) error {
subCommandsDeploy = append(subCommandsDeploy, commandDeploy) subCommandsDeploy = append(subCommandsDeploy, commandDeploy)
if _, ok := gapiObj.(gapi.GettableGAPI); ok { if _, ok := gapiObj.(gapi.GettableGAPI); ok {
commandGet := cli.Command{ commandGet := &cli.Command{
Name: name, Name: name,
Usage: fmt.Sprintf("get (download) using the `%s` frontend", name), Usage: fmt.Sprintf("get (download) using the `%s` frontend", name),
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
@@ -329,13 +329,13 @@ func CLI(program, version string, flags Flags) error {
// global flags // global flags
app.Flags = []cli.Flag{ app.Flags = []cli.Flag{
cli.BoolFlag{ &cli.BoolFlag{
Name: "license", Name: "license",
Usage: "prints the software license", Usage: "prints the software license",
}, },
} }
app.Commands = []cli.Command{ app.Commands = []*cli.Command{
//{ //{
// Name: gapi.CommandTODO, // Name: gapi.CommandTODO,
// Aliases: []string{"TODO"}, // 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 // agnostic to which frontend is running, in fact, you can deploy with
// multiple different frontends, one after another, on the same engine. // multiple different frontends, one after another, on the same engine.
if len(subCommandsRun) > 0 { if len(subCommandsRun) > 0 {
commandRun := cli.Command{ commandRun := &cli.Command{
Name: gapi.CommandRun, Name: gapi.CommandRun,
Aliases: []string{"r"}, Aliases: []string{"r"},
Usage: "run", Usage: "run",
@@ -361,7 +361,7 @@ func CLI(program, version string, flags Flags) error {
} }
if len(subCommandsDeploy) > 0 { if len(subCommandsDeploy) > 0 {
commandDeploy := cli.Command{ commandDeploy := &cli.Command{
Name: gapi.CommandDeploy, Name: gapi.CommandDeploy,
Aliases: []string{"d"}, Aliases: []string{"d"},
Usage: "deploy", Usage: "deploy",
@@ -372,7 +372,7 @@ func CLI(program, version string, flags Flags) error {
} }
if len(subCommandsGet) > 0 { if len(subCommandsGet) > 0 {
commandGet := cli.Command{ commandGet := &cli.Command{
Name: gapi.CommandGet, Name: gapi.CommandGet,
Aliases: []string{"g"}, Aliases: []string{"g"},
Usage: "get", Usage: "get",

View File

@@ -44,7 +44,7 @@ const (
// deploy is the cli target to manage deploys to our cluster. // deploy is the cli target to manage deploys to our cluster.
// TODO: add a timeout and/or cancel signal to replace context.TODO() // TODO: add a timeout and/or cancel signal to replace context.TODO()
func deploy(c *cli.Context, name string, gapiObj gapi.GAPI) error { func deploy(c *cli.Context, name string, gapiObj gapi.GAPI) error {
cliContext := c.Parent() cliContext := c.Lineage()[1]
if cliContext == nil { if cliContext == nil {
return fmt.Errorf("could not get cli context") return fmt.Errorf("could not get cli context")
} }

View File

@@ -28,7 +28,7 @@ import (
// get is the cli target to run code/import downloads. // get is the cli target to run code/import downloads.
func get(c *cli.Context, name string, gapiObj gapi.GAPI) error { func get(c *cli.Context, name string, gapiObj gapi.GAPI) error {
cliContext := c.Parent() cliContext := c.Lineage()[1]
if cliContext == nil { if cliContext == nil {
return fmt.Errorf("could not get cli context") return fmt.Errorf("could not get cli context")
} }

View File

@@ -35,7 +35,7 @@ import (
// run is the main run target. // run is the main run target.
func run(c *cli.Context, name string, gapiObj gapi.GAPI) error { 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 { if cliContext == nil {
return fmt.Errorf("could not get cli context") return fmt.Errorf("could not get cli context")
} }

View File

@@ -70,7 +70,7 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag {
fallthrough fallthrough
case gapi.CommandDeploy: case gapi.CommandDeploy:
return []cli.Flag{ return []cli.Flag{
cli.StringFlag{ &cli.StringFlag{
Name: "puppet-conf", Name: "puppet-conf",
Value: "", Value: "",
Usage: "the path to an alternate puppet.conf file", 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{ return &gapi.Deploy{
Name: Name, Name: Name,
Noop: c.GlobalBool("noop"), Noop: c.Bool("noop"),
Sema: c.GlobalInt("sema"), Sema: c.Int("sema"),
GAPI: &GAPI{ GAPI: &GAPI{
InputURI: fs.URI(), InputURI: fs.URI(),
Mode: mode, Mode: mode,

View File

@@ -93,8 +93,8 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {
return &gapi.Deploy{ return &gapi.Deploy{
Name: Name, Name: Name,
Noop: c.GlobalBool("noop"), Noop: c.Bool("noop"),
Sema: c.GlobalInt("sema"), Sema: c.Int("sema"),
GAPI: &GAPI{ GAPI: &GAPI{
InputURI: fs.URI(), InputURI: fs.URI(),
// TODO: add properties here... // TODO: add properties here...