fix: downgrade urfave/cli to v1 to enable more flexible parsing (#154)

This commit is contained in:
Daniel Moran
2021-06-28 14:49:26 -04:00
committed by GitHub
parent 72d1ad8361
commit ead44e4e83
29 changed files with 534 additions and 639 deletions

View File

@ -3,66 +3,56 @@ package main
import (
"github.com/influxdata/influx-cli/v2/clients/setup"
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
"github.com/urfave/cli/v2"
"github.com/urfave/cli"
)
func newSetupCmd() *cli.Command {
func newSetupCmd() cli.Command {
var params setup.Params
return &cli.Command{
return cli.Command{
Name: "setup",
Usage: "Setup instance with initial user, org, bucket",
Before: middleware.WithBeforeFns(withCli(), withApi(false)),
Flags: append(
commonFlagsNoToken(),
&cli.StringFlag{
Name: "username",
Name: "username, u",
Usage: "Name of initial user to create",
Aliases: []string{"u"},
Destination: &params.Username,
},
&cli.StringFlag{
Name: "password",
Name: "password, p",
Usage: "Password to set on initial user",
Aliases: []string{"p"},
Destination: &params.Password,
},
&cli.StringFlag{
Name: tokenFlagName,
Name: tokenFlagName + ", t",
Usage: "Auth token to set on the initial user",
Aliases: []string{"t"},
EnvVars: []string{"INFLUX_TOKEN"},
DefaultText: "auto-generated",
EnvVar: "INFLUX_TOKEN",
Destination: &params.AuthToken,
},
&cli.StringFlag{
Name: "org",
Name: "org, o",
Usage: "Name of initial organization to create",
Aliases: []string{"o"},
Destination: &params.Org,
},
&cli.StringFlag{
Name: "bucket",
Name: "bucket, b",
Usage: "Name of initial bucket to create",
Aliases: []string{"b"},
Destination: &params.Bucket,
},
&cli.StringFlag{
Name: "retention",
Name: "retention, r",
Usage: "Duration initial bucket will retain data, or 0 for infinite",
Aliases: []string{"r"},
DefaultText: "infinite",
Destination: &params.Retention,
},
&cli.BoolFlag{
Name: "force",
Name: "force, f",
Usage: "Skip confirmation prompt",
Aliases: []string{"f"},
Destination: &params.Force,
},
&cli.StringFlag{
Name: "name",
Name: "name, n",
Usage: "Name to set on CLI config generated for the InfluxDB instance, required if other configs exist",
Aliases: []string{"n"},
Destination: &params.ConfigName,
},
),
@ -71,7 +61,7 @@ func newSetupCmd() *cli.Command {
CLI: getCLI(ctx),
SetupApi: getAPINoToken(ctx).SetupApi,
}
return client.Setup(ctx.Context, &params)
return client.Setup(getContext(ctx), &params)
},
}
}