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

cli: Make "unknown sub-command" error clearer for empty subcommands #30727

Merged
merged 1 commit into from
Sep 27, 2018

Conversation

a-robinson
Copy link
Contributor

I ran cockroach zone to try and get the list of available sub-commands
printed as help text, but ended up getting confused by what it printed:

Error: unknown sub-command:
Failed running "zone"

I wasn't really sure what this meant. Now it'll print:

Error: unknown sub-command: ""
Failed running "zone"

It may also be better to say something like "unknown or missing
sub-command". Let me know if you'd prefer that.

Release note: None


Along these lines, how come the available subcommands don't get printed anymore? I can't get them listed either with cockroach zone or cockroach zone -h. I could have sworn we used to list them. Did cobra change? Maybe I'm conflating cockroach with other tools. It'd certainly be nice if we did, though.

I ran `cockroach zone` to try and get the list of available sub-commands
printed as help text, but ended up getting confused by what it printed:

Error: unknown sub-command:
Failed running "zone"

I wasn't really sure what this meant. Now it'll print:

Error: unknown sub-command: ""
Failed running "zone"

It may also be better to say something like "unknown or missing
sub-command". Let me know if you'd prefer that.

Release note: None
@a-robinson a-robinson requested a review from knz September 27, 2018 17:35
@a-robinson a-robinson requested a review from a team as a code owner September 27, 2018 17:35
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@knz
Copy link
Contributor

knz commented Sep 27, 2018

What you have now LGTM

The other suggestion LGTM too!

Pick your preferred outcome. Either is better than the status quo. Thanks for finding this out.

@a-robinson
Copy link
Contributor Author

Thanks for the quick review. Also, I double checked, and not printing the subcommands is a regression since 2.0. I'll open a separate issue, but do you have any available time to look into it?

~ 0 $ Downloads/cockroach-v2.0.3.darwin-10.9-amd64/cockroach zone
Usage:
  cockroach zone [flags]
  cockroach zone [command]

Available Commands:
  get         fetches and displays the zone config
  ls          list all zone configs
  rm          remove a zone config
  set         create or update zone config for object ID

Flags:
  -h, --help   help for zone

Global Flags:
      --log-backtrace-at traceLocation   when logging hits line file:N, emit a stack trace (default :0)
      --log-dir string                   if non-empty, write log files in this directory
      --log-dir-max-size bytes           maximum combined size of all log files (default 100 MiB)
      --log-file-max-size bytes          maximum size of each log file (default 10 MiB)
      --log-file-verbosity Severity      minimum verbosity of messages written to the log file (default INFO)
      --logtostderr Severity[=DEFAULT]   logs at or above this threshold go to stderr (default NONE)
      --no-color                         disable standard error log colorization
      --verbosity level                  log level for V logs
      --vmodule moduleSpec               comma-separated list of pattern=N settings for file-filtered logging

Use "cockroach zone [command] --help" for more information about a command.
~ 0 $ Downloads/cockroach-v2.1.0-beta.20180924.darwin-10.9-amd64/cockroach zone
Usage:
  cockroach zone [flags]

Flags:
  -h, --help   help for zone

Global Flags:
      --log-dir string                   if non-empty, write log files in this directory
      --log-dir-max-size bytes           maximum combined size of all log files (default 100 MiB)
      --log-file-max-size bytes          maximum size of each log file (default 10 MiB)
      --log-file-verbosity Severity      minimum verbosity of messages written to the log file (default INFO)
      --logtostderr Severity[=DEFAULT]   logs at or above this threshold go to stderr (default NONE)
      --no-color                         disable standard error log colorization
      --vmodule moduleSpec               comma-separated list of pattern=N settings for file-filtered logging (significantly hurts performance)
Error: unknown sub-command:
Failed running "zone"
~ 1 $

@a-robinson
Copy link
Contributor Author

bors r+

craig bot pushed a commit that referenced this pull request Sep 27, 2018
30530: opt: Fix bug in function interning. r=andy-kimball a=andy-kimball

Some builtin function overloads have a return type that's dependent on
the type of its parameters (e.g. unnest). This means that two FuncOpDef
structs with the same overload can have different Type fields. Therefore,
the FuncOpDef interning needs to incorporate that type.

Release note: None

30608: sqlbase: introduce RowFetcher.Reset() r=jordanlewis a=jordanlewis

In preparation for pooling tableReader objects and reusing internal
allocated memory.

Broken out from #30556.

Release note: None

30727: cli: Make "unknown sub-command" error clearer for empty subcommands r=a-robinson a=a-robinson

I ran `cockroach zone` to try and get the list of available sub-commands
printed as help text, but ended up getting confused by what it printed:

Error: unknown sub-command:
Failed running "zone"

I wasn't really sure what this meant. Now it'll print:

Error: unknown sub-command: ""
Failed running "zone"

It may also be better to say something like "unknown or missing
sub-command". Let me know if you'd prefer that.

Release note: None

---

Along these lines, how come the available subcommands don't get printed anymore? I can't get them listed either with `cockroach zone` or `cockroach zone -h`. I could have sworn we used to list them. Did cobra change? Maybe I'm conflating cockroach with other tools. It'd certainly be nice if we did, though.

Co-authored-by: Andrew Kimball <andyk@cockroachlabs.com>
Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
Co-authored-by: Alex Robinson <alexdwanerobinson@gmail.com>
@craig
Copy link
Contributor

craig bot commented Sep 27, 2018

Build succeeded

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

Successfully merging this pull request may close these issues.

3 participants