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.
If we use
standalone_mode=Truepassing arguments to command execution will not callsys.exit, except if the argument to the command is["--help"].From inside ipython:
Expected:
--helpparameter in standalone mode does not callsys.exit.