You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
standalone_mode does not affect the help option #667
If we use standalone_mode=True passing arguments to command execution will not call sys.exit, except if the argument to the command is ["--help"].
From inside ipython:
In [12]: import click
In [13]: @click.command()
...: def hello():
...: print("hello, world")
...:
In [14]: hello.main([], standalone_mode=False)
hello, world
In [15]: hello.main(['wrong_arg'], standalone_mode=False)
UsageError Traceback (most recent call last)
in ()
...
UsageError: Got unexpected extra argument (wrong_arg)
In [16]: hello.main(['--help'], standalone_mode=False)
Usage: ipython [OPTIONS]
Options:
--help Show this message and exit.
An exception has occurred, use %tb to see the full traceback.
SystemExit: 0
/Users/malkarouri/Library/Python/2.7/lib/python/site-packages/IPython/core/interactiveshell.py:2889: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
Expected: --help parameter in standalone mode does not call sys.exit.
Activity
jamesmyatt commentedon Mar 3, 2018
I think you mean "standalone_mode=False", but I agree. The offending line is https://github.com/pallets/click/blob/master/click/core.py#L1030. Compare with the Command.main: https://github.com/pallets/click/blob/master/click/core.py#L707
This is important since it makes debugging harder.
Simplify Exit Exception
Simplify Exit Exception
Simplify Exit Exception
Simplify Exit Exception
Simplify Exit Exception
Merge #1576
Merge #37
Update click to 7.0 (#97)