Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unkown subcommand doesn't return any errors #111

Closed
navidshaikh opened this issue May 15, 2019 · 3 comments
Closed

Unkown subcommand doesn't return any errors #111

navidshaikh opened this issue May 15, 2019 · 3 comments
Assignees
Milestone

Comments

@navidshaikh
Copy link
Collaborator

For example, we've renamed kn service list -> kn service get, however if ran list, it just shows the help text for service group and doesn't return with exit status 1 or prints that list is unkown command.

➜ kn service list
Service command group

Usage:
  kn service [command]

Available Commands:
  create      Create a service.
  delete      Delete a service.
  describe    Describe available services.
  get         Get available services.
  update      Update a service.

Flags:
  -h, --help   help for service

Global Flags:
      --config string       config file (default is $HOME/.kn.yaml)
      --kubeconfig string   kubectl config file (default is $HOME/.kube/config)

Use "kn service [command] --help" for more information about a command.
➜ echo $?
0

This seems to be a known inconsistency with only sub-commands and not with commands.

However, we've a false positive https://github.com/knative/client/blob/master/test/e2e-tests.sh#L50 .

navidshaikh added a commit to navidshaikh/client that referenced this issue May 15, 2019
 Fixes knative#111
 ```
 ➜ ./kn service list
 unknown command "list" for "kn service"
 ➜ echo $?
 1
 ➜ ./kn revision list
 unknown command "list" for "kn revision"
 ➜ echo $?
 1
 ```
@sixolet sixolet added this to the v0.2.0 milestone May 28, 2019
@navidshaikh
Copy link
Collaborator Author

Issue at spf13/cobra#706

@maximilien
Copy link
Contributor

We can easily fix this for all command grouped. I'll submit a PR and we can discuss details there.

/assign @maximilien

maximilien added a commit to maximilien/client that referenced this issue Jun 18, 2019
…mmands

```bash
➜  client git:(issue111) ✗ ./kn service unknown
unknown command "unknown" for "kn service"
```

This works for both the `service` and `revision` groups.
maximilien added a commit to maximilien/client that referenced this issue Jun 19, 2019
…mmands

```bash
➜  client git:(issue111) ✗ ./kn service unknown
unknown command "unknown" for "kn service"

➜  client git:(issue111) ✗ ./kn revision
please provide a valid sub-command for "kn revision"
```

This works for both the `service` and `revision` groups.
maximilien added a commit to maximilien/client that referenced this issue Jun 20, 2019
…mmands

```bash
➜  client git:(issue111) ✗ ./kn service unknown
Service command group

Usage:
  kn service [flags]
  kn service [command]

Available Commands:
  create      Create a service.
  delete      Delete a service.
  describe    Describe available services.
  list        List available services.
  update      Update a service.

Flags:
  -h, --help   help for service

Global Flags:
      --kubeconfig string   kubectl config file (default is $HOME/.kube/config)

Use "kn service [command] --help" for more information about a command.
unknown command "unknown" for "kn service"

➜  client git:(issue111) ✗ ./kn revision lol
Revision command group

Usage:
  kn revision [flags]
  kn revision [command]

Available Commands:
  describe    Describe revisions.
  list        List available revisions.

Flags:
  -h, --help   help for revision

Global Flags:
      --kubeconfig string   kubectl config file (default is $HOME/.kube/config)

Use "kn revision [command] --help" for more information about a command.
unknown command "lol" for "kn revision"
```

This works for both the `service` and `revision` groups whe called with empty and unknown sub-command.
maximilien added a commit to maximilien/client that referenced this issue Jul 1, 2019
…mmands

```bash
➜  client git:(issue111) ✗ ./kn service unknown
Service command group

Usage:
  kn service [flags]
  kn service [command]

Available Commands:
  create      Create a service.
  delete      Delete a service.
  describe    Describe available services.
  list        List available services.
  update      Update a service.

Flags:
  -h, --help   help for service

Global Flags:
      --kubeconfig string   kubectl config file (default is $HOME/.kube/config)

Use "kn service [command] --help" for more information about a command.
unknown command "unknown" for "kn service"

➜  client git:(issue111) ✗ ./kn revision lol
Revision command group

Usage:
  kn revision [flags]
  kn revision [command]

Available Commands:
  describe    Describe revisions.
  list        List available revisions.

Flags:
  -h, --help   help for revision

Global Flags:
      --kubeconfig string   kubectl config file (default is $HOME/.kube/config)

Use "kn revision [command] --help" for more information about a command.
unknown command "lol" for "kn revision"
```

This works for both the `service` and `revision` groups whe called with empty and unknown sub-command.
maximilien added a commit to maximilien/client that referenced this issue Jul 1, 2019
Explores all sub-commands from root and adds a RunE for all
commands that are groups with child commands and without a RunE.
The added RunE will return the correct errors when the command
is called with empty sub-command or with an unknown sub-command.
It will also print the command help message first.
maximilien added a commit to maximilien/client that referenced this issue Jul 1, 2019
Explores all sub-commands from root and adds a RunE for all
commands that are groups with child commands and without a RunE.
The added RunE will return the correct errors when the command
is called with empty sub-command or with an unknown sub-command.
It will also print the command help message first.
maximilien added a commit to maximilien/client that referenced this issue Jul 2, 2019
Explores all sub-commands from root and adds a RunE for all
commands that are groups with child commands and without a RunE.
The added RunE will return the correct errors when the command
is called with empty sub-command or with an unknown sub-command.
It will also print the command help message first.
maximilien added a commit to maximilien/client that referenced this issue Jul 2, 2019
Explores all sub-commands from root and adds a RunE for all
commands that are groups with child commands and without a RunE.
The added RunE will return the correct errors when the command
is called with empty sub-command or with an unknown sub-command.
It will also print the command help message first.
maximilien added a commit to maximilien/client that referenced this issue Jul 2, 2019
Explores all sub-commands from root and adds a RunE for all
commands that are groups with child commands and without a RunE.
The added RunE will return the correct errors when the command
is called with empty sub-command or with an unknown sub-command.
It will also print the command help message first.
maximilien added a commit to maximilien/client that referenced this issue Jul 2, 2019
Explores all sub-commands from root and adds a RunE for all
commands that are groups with child commands and without a RunE.
The added RunE will return the correct errors when the command
is called with empty sub-command or with an unknown sub-command.
It will also print the command help message first.

Added a gotest.tools test for root.go.
maximilien added a commit to maximilien/client that referenced this issue Jul 2, 2019
Explores all sub-commands from root and adds a RunE for all
commands that are groups with child commands and without a RunE.
The added RunE will return the correct errors when the command
is called with empty sub-command or with an unknown sub-command.
It will also print the command help message first.

Added a gotest.tools test for root.go.
maximilien added a commit to maximilien/client that referenced this issue Jul 2, 2019
Explores all sub-commands from root and adds a RunE for all
commands that are groups with child commands and without a RunE.
The added RunE will return the correct errors when the command
is called with empty sub-command or with an unknown sub-command.
It will also print the command help message first.

Added a gotest.tools test for root.go.
maximilien added a commit to maximilien/client that referenced this issue Jul 3, 2019
Explores all sub-commands from root and adds a RunE for all
commands that are groups with child commands and without a RunE.
The added RunE will return the correct errors when the command
is called with empty sub-command or with an unknown sub-command.
It will also print the command help message first.

Added a gotest.tools test for root.go.
maximilien added a commit to maximilien/client that referenced this issue Jul 3, 2019
Explores all sub-commands from root and adds a RunE for all
commands that are groups with child commands and without a RunE.
The added RunE will return the correct errors when the command
is called with empty sub-command or with an unknown sub-command.
It will also print the command help message first.

Added a gotest.tools test for root.go.
knative-prow-robot pushed a commit that referenced this issue Jul 3, 2019
Explores all sub-commands from root and adds a RunE for all
commands that are groups with child commands and without a RunE.
The added RunE will return the correct errors when the command
is called with empty sub-command or with an unknown sub-command.
It will also print the command help message first.

Added a gotest.tools test for root.go.
@navidshaikh
Copy link
Collaborator Author

Fixed by #218

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants