Set up shell command-line tab-completion using argcomplete and ipython/traitlets#811. Completion requires argcomplete to be activated and traitlets>=5.8. Behavior is only changed when $_ARGCOMPLETE is set, so there should be no difference in behavior otherwise.
For subcommand handling, this will use list_subcommands() to try to complete the first argument if it doesn't start with a "-", and when a subcommand is detected, argcomplete will increment the start of the command-line handling past the subcommand and drop into the relevant traitlets.Application's argcomplete handling. All of the major subcommands like jupyter lab directly use traitlets.Application.launch_instance so this works pretty seamlessly. However, completing commands that start with the hyphenated commands, e.g. jupyter-lab, would still require the addition of the PYTHON_ARGCOMPLETE_OK marker in the respective projects' main scripts. Note that argcomplete supports following setuptools console_scripts to the corresponding main script to look for the PYTHON_ARGCOMPLETE_OK marker.
Set up shell command-line tab-completion using
argcomplete
and ipython/traitlets#811. Completion requiresargcomplete
to be activated andtraitlets>=5.8
. Behavior is only changed when$_ARGCOMPLETE
is set, so there should be no difference in behavior otherwise.For subcommand handling, this will use
list_subcommands()
to try to complete the first argument if it doesn't start with a "-", and when a subcommand is detected,argcomplete
will increment the start of the command-line handling past the subcommand and drop into the relevanttraitlets.Application
's argcomplete handling. All of the major subcommands likejupyter lab
directly usetraitlets.Application.launch_instance
so this works pretty seamlessly. However, completing commands that start with the hyphenated commands, e.g.jupyter-lab
, would still require the addition of thePYTHON_ARGCOMPLETE_OK
marker in the respective projects' main scripts. Note that argcomplete supports following setuptoolsconsole_scripts
to the corresponding main script to look for thePYTHON_ARGCOMPLETE_OK
marker.Example: