fix: downgrade urfave/cli to v1 to enable more flexible parsing (#154)
This commit is contained in:
@ -4,14 +4,14 @@ import (
|
||||
"github.com/influxdata/influx-cli/v2/clients/user"
|
||||
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
|
||||
"github.com/influxdata/influx-cli/v2/pkg/influxid"
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
func newUserCmd() *cli.Command {
|
||||
return &cli.Command{
|
||||
func newUserCmd() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "user",
|
||||
Usage: "User management commands",
|
||||
Subcommands: []*cli.Command{
|
||||
Subcommands: []cli.Command{
|
||||
newUserCreateCmd(),
|
||||
newUserDeleteCmd(),
|
||||
newUserListCmd(),
|
||||
@ -21,38 +21,35 @@ func newUserCmd() *cli.Command {
|
||||
}
|
||||
}
|
||||
|
||||
func newUserCreateCmd() *cli.Command {
|
||||
func newUserCreateCmd() cli.Command {
|
||||
var params user.CreateParams
|
||||
return &cli.Command{
|
||||
return cli.Command{
|
||||
Name: "create",
|
||||
Usage: "Create user",
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.GenericFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization",
|
||||
EnvVars: []string{"INFLUX_ORG_ID"},
|
||||
Value: ¶ms.OrgID,
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Value: ¶ms.OrgID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org",
|
||||
Name: "org, o",
|
||||
Usage: "The name of the organization",
|
||||
Aliases: []string{"o"},
|
||||
EnvVars: []string{"INFLUX_ORG"},
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.OrgName,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "name",
|
||||
Name: "name, n",
|
||||
Usage: "The user name",
|
||||
Aliases: []string{"n"},
|
||||
EnvVars: []string{"INFLUX_NAME"},
|
||||
EnvVar: "INFLUX_NAME",
|
||||
Required: true,
|
||||
Destination: ¶ms.Name,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "password",
|
||||
Name: "password, p",
|
||||
Usage: "The user password",
|
||||
Aliases: []string{"p"},
|
||||
Destination: ¶ms.Password,
|
||||
},
|
||||
),
|
||||
@ -64,22 +61,21 @@ func newUserCreateCmd() *cli.Command {
|
||||
UsersApi: api.UsersApi,
|
||||
OrganizationsApi: api.OrganizationsApi,
|
||||
}
|
||||
return client.Create(ctx.Context, ¶ms)
|
||||
return client.Create(getContext(ctx), ¶ms)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newUserDeleteCmd() *cli.Command {
|
||||
func newUserDeleteCmd() cli.Command {
|
||||
var id influxid.ID
|
||||
return &cli.Command{
|
||||
return cli.Command{
|
||||
Name: "delete",
|
||||
Usage: "Delete user",
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.GenericFlag{
|
||||
Name: "id",
|
||||
Name: "id, i",
|
||||
Usage: "The user ID",
|
||||
Aliases: []string{"i"},
|
||||
Required: true,
|
||||
Value: &id,
|
||||
},
|
||||
@ -87,91 +83,85 @@ func newUserDeleteCmd() *cli.Command {
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
client := user.Client{CLI: getCLI(ctx), UsersApi: getAPI(ctx).UsersApi}
|
||||
return client.Delete(ctx.Context, id)
|
||||
return client.Delete(getContext(ctx), id)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newUserListCmd() *cli.Command {
|
||||
func newUserListCmd() cli.Command {
|
||||
var params user.ListParams
|
||||
return &cli.Command{
|
||||
return cli.Command{
|
||||
Name: "list",
|
||||
Aliases: []string{"find", "ls"},
|
||||
Usage: "List users",
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.GenericFlag{
|
||||
Name: "id",
|
||||
Usage: "The user ID",
|
||||
Aliases: []string{"i"},
|
||||
Value: ¶ms.Id,
|
||||
Name: "id, i",
|
||||
Usage: "The user ID",
|
||||
Value: ¶ms.Id,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "name",
|
||||
Name: "name, n",
|
||||
Usage: "The user name",
|
||||
Aliases: []string{"n"},
|
||||
Destination: ¶ms.Name,
|
||||
},
|
||||
),
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
client := user.Client{CLI: getCLI(ctx), UsersApi: getAPI(ctx).UsersApi}
|
||||
return client.List(ctx.Context, ¶ms)
|
||||
return client.List(getContext(ctx), ¶ms)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newUserUpdateCmd() *cli.Command {
|
||||
func newUserUpdateCmd() cli.Command {
|
||||
var params user.UpdateParmas
|
||||
return &cli.Command{
|
||||
return cli.Command{
|
||||
Name: "update",
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.GenericFlag{
|
||||
Name: "id",
|
||||
Name: "id, i",
|
||||
Usage: "The user ID",
|
||||
Aliases: []string{"i"},
|
||||
Required: true,
|
||||
Value: ¶ms.Id,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "name",
|
||||
Name: "name, n",
|
||||
Usage: "The user name",
|
||||
Aliases: []string{"n"},
|
||||
Destination: ¶ms.Name,
|
||||
},
|
||||
),
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
client := user.Client{CLI: getCLI(ctx), UsersApi: getAPI(ctx).UsersApi}
|
||||
return client.Update(ctx.Context, ¶ms)
|
||||
return client.Update(getContext(ctx), ¶ms)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newUserSetPasswordCmd() *cli.Command {
|
||||
func newUserSetPasswordCmd() cli.Command {
|
||||
var params user.SetPasswordParams
|
||||
return &cli.Command{
|
||||
return cli.Command{
|
||||
Name: "password",
|
||||
Flags: append(
|
||||
commonFlagsNoPrint(),
|
||||
&cli.GenericFlag{
|
||||
Name: "id",
|
||||
Usage: "The user ID",
|
||||
Aliases: []string{"i"},
|
||||
Value: ¶ms.Id,
|
||||
Name: "id, i",
|
||||
Usage: "The user ID",
|
||||
Value: ¶ms.Id,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "name",
|
||||
Name: "name, n",
|
||||
Usage: "The user name",
|
||||
Aliases: []string{"n"},
|
||||
Destination: ¶ms.Name,
|
||||
},
|
||||
),
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
client := user.Client{CLI: getCLI(ctx), UsersApi: getAPI(ctx).UsersApi}
|
||||
return client.SetPassword(ctx.Context, ¶ms)
|
||||
return client.SetPassword(getContext(ctx), ¶ms)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user