fix: return "unknown command" instead of "no help topic" error when unknown (sub)command is passed (#316)
Co-authored-by: Sam Lai <samuel.lai@gmail.com>
This commit is contained in:
@ -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]
|
## v2.2.0 [2021-10-21]
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
@ -13,6 +13,7 @@ func newAuthCommand() cli.Command {
|
|||||||
Name: "auth",
|
Name: "auth",
|
||||||
Usage: "Authorization management commands",
|
Usage: "Authorization management commands",
|
||||||
Aliases: []string{"authorization"},
|
Aliases: []string{"authorization"},
|
||||||
|
Before: middleware.NoArgs,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
newCreateCommand(),
|
newCreateCommand(),
|
||||||
newDeleteCommand(),
|
newDeleteCommand(),
|
||||||
|
@ -9,8 +9,9 @@ import (
|
|||||||
|
|
||||||
func newBucketCmd() cli.Command {
|
func newBucketCmd() cli.Command {
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "bucket",
|
Name: "bucket",
|
||||||
Usage: "Bucket management commands",
|
Usage: "Bucket management commands",
|
||||||
|
Before: middleware.NoArgs,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
newBucketCreateCmd(),
|
newBucketCreateCmd(),
|
||||||
newBucketDeleteCmd(),
|
newBucketDeleteCmd(),
|
||||||
|
@ -36,8 +36,9 @@ func getBucketSchemaClient(ctx *cli.Context) bucket_schema.Client {
|
|||||||
|
|
||||||
func newBucketSchemaCmd() cli.Command {
|
func newBucketSchemaCmd() cli.Command {
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "bucket-schema",
|
Name: "bucket-schema",
|
||||||
Usage: "Bucket schema management commands",
|
Usage: "Bucket schema management commands",
|
||||||
|
Before: middleware.NoArgs,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
newBucketSchemaCreateCmd(),
|
newBucketSchemaCreateCmd(),
|
||||||
newBucketSchemaUpdateCmd(),
|
newBucketSchemaUpdateCmd(),
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ var app = cli.App{
|
|||||||
newRemoteCmd(),
|
newRemoteCmd(),
|
||||||
newReplicationCmd(),
|
newReplicationCmd(),
|
||||||
},
|
},
|
||||||
Before: withContext(),
|
Before: middleware.WithBeforeFns(withContext(), middleware.NoArgs),
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -12,6 +12,7 @@ func newOrgCmd() cli.Command {
|
|||||||
Name: "org",
|
Name: "org",
|
||||||
Aliases: []string{"organization"},
|
Aliases: []string{"organization"},
|
||||||
Usage: "Organization management commands",
|
Usage: "Organization management commands",
|
||||||
|
Before: middleware.NoArgs,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
newOrgCreateCmd(),
|
newOrgCreateCmd(),
|
||||||
newOrgDeleteCmd(),
|
newOrgDeleteCmd(),
|
||||||
|
@ -8,8 +8,9 @@ import (
|
|||||||
|
|
||||||
func newOrgMembersCmd() cli.Command {
|
func newOrgMembersCmd() cli.Command {
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "members",
|
Name: "members",
|
||||||
Usage: "Organization membership commands",
|
Usage: "Organization membership commands",
|
||||||
|
Before: middleware.NoArgs,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
newOrgMembersAddCmd(),
|
newOrgMembersAddCmd(),
|
||||||
newOrgMembersListCmd(),
|
newOrgMembersListCmd(),
|
||||||
|
@ -11,6 +11,7 @@ func newRemoteCmd() cli.Command {
|
|||||||
Name: "remote",
|
Name: "remote",
|
||||||
Usage: "Remote connection management commands",
|
Usage: "Remote connection management commands",
|
||||||
Hidden: true, // Remove this line when all subcommands are completed
|
Hidden: true, // Remove this line when all subcommands are completed
|
||||||
|
Before: middleware.NoArgs,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
newRemoteCreateCmd(),
|
newRemoteCreateCmd(),
|
||||||
newRemoteDeleteCmd(),
|
newRemoteDeleteCmd(),
|
||||||
|
@ -11,6 +11,7 @@ func newReplicationCmd() cli.Command {
|
|||||||
Name: "replication",
|
Name: "replication",
|
||||||
Usage: "Replication stream management commands",
|
Usage: "Replication stream management commands",
|
||||||
Hidden: true, // Remove this line when all subcommands are completed
|
Hidden: true, // Remove this line when all subcommands are completed
|
||||||
|
Before: middleware.NoArgs,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
newReplicationCreateCmd(),
|
newReplicationCreateCmd(),
|
||||||
newReplicationDeleteCmd(),
|
newReplicationDeleteCmd(),
|
||||||
|
@ -8,8 +8,9 @@ import (
|
|||||||
|
|
||||||
func newSecretCommand() cli.Command {
|
func newSecretCommand() cli.Command {
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "secret",
|
Name: "secret",
|
||||||
Usage: "Secret management commands",
|
Usage: "Secret management commands",
|
||||||
|
Before: middleware.NoArgs,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
newDeleteSecretCmd(),
|
newDeleteSecretCmd(),
|
||||||
newListSecretCmd(),
|
newListSecretCmd(),
|
||||||
|
@ -11,8 +11,9 @@ const TaskMaxPageSize = 500
|
|||||||
|
|
||||||
func newTaskCommand() cli.Command {
|
func newTaskCommand() cli.Command {
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "task",
|
Name: "task",
|
||||||
Usage: "Task management commands",
|
Usage: "Task management commands",
|
||||||
|
Before: middleware.NoArgs,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
newTaskLogCmd(),
|
newTaskLogCmd(),
|
||||||
newTaskRunCmd(),
|
newTaskRunCmd(),
|
||||||
@ -264,8 +265,9 @@ func newTaskLogFindCmd() cli.Command {
|
|||||||
|
|
||||||
func newTaskRunCmd() cli.Command {
|
func newTaskRunCmd() cli.Command {
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "run",
|
Name: "run",
|
||||||
Usage: "Run related commands",
|
Usage: "Run related commands",
|
||||||
|
Before: middleware.NoArgs,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
newTaskRunFindCmd(),
|
newTaskRunFindCmd(),
|
||||||
newTaskRunRetryCmd(),
|
newTaskRunRetryCmd(),
|
||||||
|
@ -9,8 +9,9 @@ import (
|
|||||||
|
|
||||||
func newUserCmd() cli.Command {
|
func newUserCmd() cli.Command {
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "user",
|
Name: "user",
|
||||||
Usage: "User management commands",
|
Usage: "User management commands",
|
||||||
|
Before: middleware.NoArgs,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
newUserCreateCmd(),
|
newUserCreateCmd(),
|
||||||
newUserDeleteCmd(),
|
newUserDeleteCmd(),
|
||||||
|
@ -28,6 +28,7 @@ func newV1AuthCommand() cli.Command {
|
|||||||
Name: "auth",
|
Name: "auth",
|
||||||
Usage: "Authorization management commands for v1 APIs",
|
Usage: "Authorization management commands for v1 APIs",
|
||||||
Aliases: []string{"authorization"},
|
Aliases: []string{"authorization"},
|
||||||
|
Before: middleware.NoArgs,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
newCreateV1AuthCmd(),
|
newCreateV1AuthCmd(),
|
||||||
newRemoveV1AuthCmd(),
|
newRemoveV1AuthCmd(),
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
package main
|
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 {
|
func newV1SubCommand() cli.Command {
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "v1",
|
Name: "v1",
|
||||||
Usage: "InfluxDB v1 management commands",
|
Usage: "InfluxDB v1 management commands",
|
||||||
|
Before: middleware.NoArgs,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
newV1DBRPCmd(),
|
newV1DBRPCmd(),
|
||||||
newV1AuthCommand(),
|
newV1AuthCommand(),
|
||||||
|
@ -8,8 +8,9 @@ import (
|
|||||||
|
|
||||||
func newV1DBRPCmd() cli.Command {
|
func newV1DBRPCmd() cli.Command {
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "dbrp",
|
Name: "dbrp",
|
||||||
Usage: "Commands to manage database and retention policy mappings for v1 APIs",
|
Usage: "Commands to manage database and retention policy mappings for v1 APIs",
|
||||||
|
Before: middleware.NoArgs,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
newV1DBRPListCmd(),
|
newV1DBRPListCmd(),
|
||||||
newV1DBRPCreateCmd(),
|
newV1DBRPCreateCmd(),
|
||||||
|
Reference in New Issue
Block a user