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:
Daniel Moran 2021-11-02 14:17:42 -04:00 committed by GitHub
parent a3af8ca833
commit d861490100
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 44 additions and 20 deletions

View File

@ -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

View File

@ -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(),

View File

@ -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(),

View File

@ -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(),

View File

@ -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() {

View File

@ -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(),

View File

@ -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(),

View File

@ -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(),

View File

@ -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(),

View File

@ -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(),

View File

@ -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(),

View File

@ -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(),

View File

@ -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(),

View File

@ -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(),

View File

@ -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(),