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

Print full usage on missing or invalid commands #225

Merged
merged 3 commits into from
May 7, 2021

Conversation

ivanov
Copy link
Member

@ivanov ivanov commented May 7, 2021

prior to this commit:

$ jupyter help
Jupyter command `jupyter-help` not found.
$ echo $?
1

and

$ jupyter
usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
               [--paths] [--json] [--debug]
               [subcommand]
jupyter: error: one of the arguments --version subcommand --config-dir --data-dir --runtime-dir --paths is required
$ echo $?
1

With this PR:

$ jupyter help
usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
               [--paths] [--json] [--debug]
               [subcommand]

Jupyter: Interactive Computing

positional arguments:
  subcommand     the subcommand to launch

optional arguments:
  -h, --help     show this help message and exit
  --version      show the jupyter command's version and exit
  --config-dir   show Jupyter config dir
  --data-dir     show Jupyter data dir
  --runtime-dir  show Jupyter runtime dir
  --paths        show all Jupyter paths. Add --json for machine-readable
                 format.
  --json         output paths as machine-readable json
  --debug        output debug information about paths

Available subcommands: bundlerextension migrate nbextension notebook
serverextension troubleshoot
$ echo $?
0

and

$ jupyter
usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
               [--paths] [--json] [--debug]
               [subcommand]

Jupyter: Interactive Computing

positional arguments:
  subcommand     the subcommand to launch

optional arguments:
  -h, --help     show this help message and exit
  --version      show the jupyter command's version and exit
  --config-dir   show Jupyter config dir
  --data-dir     show Jupyter data dir
  --runtime-dir  show Jupyter runtime dir
  --paths        show all Jupyter paths. Add --json for machine-readable
                 format.
  --json         output paths as machine-readable json
  --debug        output debug information about paths

Available subcommands: bundlerextension migrate nbextension notebook
serverextension troubleshoot

Please specify a subcommand or one of the optional arguments.
$ echo $?
1

Closes #161 .

ivanov added 2 commits May 6, 2021 22:35
Closes jupyter#161

Note: though we're removing the "required=True" from the
mutually-exclusive group here, the downstream logic will still enforce
the presence of one of them, but now do so with a more useful message.
@@ -122,12 +122,12 @@ def _jupyter_abspath(subcommand):
abs_path = which(jupyter_subcommand, path=search_path)
if abs_path is None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we filter out subcommands == 'help' as a special case to avoid jupyter help printing Jupyter command 'jupyter-help' not found.? This would essentially make jupyter help == jupyter --help. I can see both arguments, but this seems a bit more friendly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I wasn't sure if special casing made sense, but the fact that git help is a command convinced me that we should treat the two equivalently. Updated the PR.

@ivanov
Copy link
Member Author

ivanov commented May 7, 2021

updated the PR description with status codes, made jupyter help behave the same as jupyter --help

Copy link
Member

@kevin-bates kevin-bates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks good Paul - thank you!

@kevin-bates kevin-bates merged commit 46a9c51 into jupyter:master May 7, 2021
@jasongrout jasongrout added this to the 4.8 milestone Aug 18, 2021
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.

Uninformative error message when running command that doesn't exist
3 participants