diff --git a/CHANGELOG.md b/CHANGELOG.md index eca00c8..c1810a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v2.3.0 [unreleased] + +### Bug Fixes + +1. [316](https://github.com/influxdata/influx-cli/pull/316): Return a better error message on unknown subcommands. Thanks @slai! + ## v2.2.0 [2021-10-21] ### Features diff --git a/cmd/influx/auth.go b/cmd/influx/auth.go index a2dcb18..d33c92d 100644 --- a/cmd/influx/auth.go +++ b/cmd/influx/auth.go @@ -13,6 +13,7 @@ func newAuthCommand() cli.Command { Name: "auth", Usage: "Authorization management commands", Aliases: []string{"authorization"}, + Before: middleware.NoArgs, Subcommands: []cli.Command{ newCreateCommand(), newDeleteCommand(), diff --git a/cmd/influx/bucket.go b/cmd/influx/bucket.go index 7404698..0e24ae6 100644 --- a/cmd/influx/bucket.go +++ b/cmd/influx/bucket.go @@ -9,8 +9,9 @@ import ( func newBucketCmd() cli.Command { return cli.Command{ - Name: "bucket", - Usage: "Bucket management commands", + Name: "bucket", + Usage: "Bucket management commands", + Before: middleware.NoArgs, Subcommands: []cli.Command{ newBucketCreateCmd(), newBucketDeleteCmd(), diff --git a/cmd/influx/bucket_schema.go b/cmd/influx/bucket_schema.go index 860cca6..bdd99a3 100644 --- a/cmd/influx/bucket_schema.go +++ b/cmd/influx/bucket_schema.go @@ -36,8 +36,9 @@ func getBucketSchemaClient(ctx *cli.Context) bucket_schema.Client { func newBucketSchemaCmd() cli.Command { return cli.Command{ - Name: "bucket-schema", - Usage: "Bucket schema management commands", + Name: "bucket-schema", + Usage: "Bucket schema management commands", + Before: middleware.NoArgs, Subcommands: []cli.Command{ newBucketSchemaCreateCmd(), newBucketSchemaUpdateCmd(), diff --git a/cmd/influx/main.go b/cmd/influx/main.go index 8c963cc..499ab9c 100644 --- a/cmd/influx/main.go +++ b/cmd/influx/main.go @@ -5,6 +5,7 @@ import ( "os" "time" + "github.com/influxdata/influx-cli/v2/pkg/cli/middleware" "github.com/urfave/cli" ) @@ -57,7 +58,7 @@ var app = cli.App{ newRemoteCmd(), newReplicationCmd(), }, - Before: withContext(), + Before: middleware.WithBeforeFns(withContext(), middleware.NoArgs), } func main() { diff --git a/cmd/influx/org.go b/cmd/influx/org.go index 84c6912..0237be4 100644 --- a/cmd/influx/org.go +++ b/cmd/influx/org.go @@ -12,6 +12,7 @@ func newOrgCmd() cli.Command { Name: "org", Aliases: []string{"organization"}, Usage: "Organization management commands", + Before: middleware.NoArgs, Subcommands: []cli.Command{ newOrgCreateCmd(), newOrgDeleteCmd(), diff --git a/cmd/influx/org_members.go b/cmd/influx/org_members.go index c35f410..90caa29 100644 --- a/cmd/influx/org_members.go +++ b/cmd/influx/org_members.go @@ -8,8 +8,9 @@ import ( func newOrgMembersCmd() cli.Command { return cli.Command{ - Name: "members", - Usage: "Organization membership commands", + Name: "members", + Usage: "Organization membership commands", + Before: middleware.NoArgs, Subcommands: []cli.Command{ newOrgMembersAddCmd(), newOrgMembersListCmd(), diff --git a/cmd/influx/remote.go b/cmd/influx/remote.go index 0eda6a1..6be5e9f 100644 --- a/cmd/influx/remote.go +++ b/cmd/influx/remote.go @@ -11,6 +11,7 @@ func newRemoteCmd() cli.Command { Name: "remote", Usage: "Remote connection management commands", Hidden: true, // Remove this line when all subcommands are completed + Before: middleware.NoArgs, Subcommands: []cli.Command{ newRemoteCreateCmd(), newRemoteDeleteCmd(), diff --git a/cmd/influx/replication.go b/cmd/influx/replication.go index 853cda9..c0cad2a 100644 --- a/cmd/influx/replication.go +++ b/cmd/influx/replication.go @@ -11,6 +11,7 @@ func newReplicationCmd() cli.Command { Name: "replication", Usage: "Replication stream management commands", Hidden: true, // Remove this line when all subcommands are completed + Before: middleware.NoArgs, Subcommands: []cli.Command{ newReplicationCreateCmd(), newReplicationDeleteCmd(), diff --git a/cmd/influx/secret.go b/cmd/influx/secret.go index d9277c1..df139af 100644 --- a/cmd/influx/secret.go +++ b/cmd/influx/secret.go @@ -8,8 +8,9 @@ import ( func newSecretCommand() cli.Command { return cli.Command{ - Name: "secret", - Usage: "Secret management commands", + Name: "secret", + Usage: "Secret management commands", + Before: middleware.NoArgs, Subcommands: []cli.Command{ newDeleteSecretCmd(), newListSecretCmd(), diff --git a/cmd/influx/task.go b/cmd/influx/task.go index ac2180e..4d58c8f 100644 --- a/cmd/influx/task.go +++ b/cmd/influx/task.go @@ -11,8 +11,9 @@ const TaskMaxPageSize = 500 func newTaskCommand() cli.Command { return cli.Command{ - Name: "task", - Usage: "Task management commands", + Name: "task", + Usage: "Task management commands", + Before: middleware.NoArgs, Subcommands: []cli.Command{ newTaskLogCmd(), newTaskRunCmd(), @@ -264,8 +265,9 @@ func newTaskLogFindCmd() cli.Command { func newTaskRunCmd() cli.Command { return cli.Command{ - Name: "run", - Usage: "Run related commands", + Name: "run", + Usage: "Run related commands", + Before: middleware.NoArgs, Subcommands: []cli.Command{ newTaskRunFindCmd(), newTaskRunRetryCmd(), diff --git a/cmd/influx/user.go b/cmd/influx/user.go index 20ed99f..2e600af 100644 --- a/cmd/influx/user.go +++ b/cmd/influx/user.go @@ -9,8 +9,9 @@ import ( func newUserCmd() cli.Command { return cli.Command{ - Name: "user", - Usage: "User management commands", + Name: "user", + Usage: "User management commands", + Before: middleware.NoArgs, Subcommands: []cli.Command{ newUserCreateCmd(), newUserDeleteCmd(), diff --git a/cmd/influx/v1_auth.go b/cmd/influx/v1_auth.go index 82fdb30..4c5265c 100644 --- a/cmd/influx/v1_auth.go +++ b/cmd/influx/v1_auth.go @@ -28,6 +28,7 @@ func newV1AuthCommand() cli.Command { Name: "auth", Usage: "Authorization management commands for v1 APIs", Aliases: []string{"authorization"}, + Before: middleware.NoArgs, Subcommands: []cli.Command{ newCreateV1AuthCmd(), newRemoveV1AuthCmd(), diff --git a/cmd/influx/v1_commands.go b/cmd/influx/v1_commands.go index 07776bf..5e2470a 100644 --- a/cmd/influx/v1_commands.go +++ b/cmd/influx/v1_commands.go @@ -1,11 +1,15 @@ package main -import "github.com/urfave/cli" +import ( + "github.com/influxdata/influx-cli/v2/pkg/cli/middleware" + "github.com/urfave/cli" +) func newV1SubCommand() cli.Command { return cli.Command{ - Name: "v1", - Usage: "InfluxDB v1 management commands", + Name: "v1", + Usage: "InfluxDB v1 management commands", + Before: middleware.NoArgs, Subcommands: []cli.Command{ newV1DBRPCmd(), newV1AuthCommand(), diff --git a/cmd/influx/v1_dbrp.go b/cmd/influx/v1_dbrp.go index 1ba6b46..4f340d4 100644 --- a/cmd/influx/v1_dbrp.go +++ b/cmd/influx/v1_dbrp.go @@ -8,8 +8,9 @@ import ( func newV1DBRPCmd() cli.Command { return cli.Command{ - Name: "dbrp", - Usage: "Commands to manage database and retention policy mappings for v1 APIs", + Name: "dbrp", + Usage: "Commands to manage database and retention policy mappings for v1 APIs", + Before: middleware.NoArgs, Subcommands: []cli.Command{ newV1DBRPListCmd(), newV1DBRPCreateCmd(),