From d6d96763e2959b8af75a5c8705cd26ccad9e428e Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Tue, 1 Sep 2020 19:23:39 -0400 Subject: Fixed docs error --- docs/api/cmd.rst | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'docs') diff --git a/docs/api/cmd.rst b/docs/api/cmd.rst index 6fdfbf27..ced49e3b 100644 --- a/docs/api/cmd.rst +++ b/docs/api/cmd.rst @@ -1,6 +1,10 @@ cmd2.Cmd ======== +.. autoclass:: cmd2.CompletionMode + :members: + :undoc-members: + .. autoclass:: cmd2.Cmd :members: -- cgit v1.2.1 From 5bc9b967d347356556d30bb04f0a2a9f7662aa06 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Sat, 5 Sep 2020 17:24:00 -0400 Subject: Made CustomCompletionSettings public since it's optionally passed to public method cmd2.Cmd.complete(). --- docs/api/cmd.rst | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'docs') diff --git a/docs/api/cmd.rst b/docs/api/cmd.rst index ced49e3b..3bcc302f 100644 --- a/docs/api/cmd.rst +++ b/docs/api/cmd.rst @@ -1,10 +1,6 @@ cmd2.Cmd ======== -.. autoclass:: cmd2.CompletionMode - :members: - :undoc-members: - .. autoclass:: cmd2.Cmd :members: @@ -69,3 +65,26 @@ cmd2.Cmd The symbol name which :ref:`features/scripting:Python Scripts` run using the :ref:`features/builtin_commands:run_pyscript` command can use to reference the parent ``cmd2`` application. + +.. autoclass:: cmd2.CompletionMode + + .. attribute:: NONE + + Tab completion will be disabled during read_input() call. Use of custom + up-arrow history supported. + + .. attribute:: COMMANDS + + read_input() will tab complete cmd2 commands and their arguments. + cmd2's command line history will be used for up arrow if history is not + provided. Otherwise use of custom up-arrow history supported. + + .. attribute:: CUSTOM + + read_input() will tab complete based on one of its following parameters + (choices, choices_provider, completer, parser). Use of custom up-arrow + history supported + +.. autoclass:: cmd2.cmd2.CustomCompletionSettings + + .. automethod:: __init__ \ No newline at end of file -- cgit v1.2.1 From d582466335d3182a15dc40bf2d8b6737fb158d46 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Wed, 9 Sep 2020 01:03:21 -0400 Subject: Moved two classes from cmd2.py to utils.py. --- docs/api/cmd.rst | 23 ----------------------- docs/api/utils.rst | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 23 deletions(-) (limited to 'docs') diff --git a/docs/api/cmd.rst b/docs/api/cmd.rst index 3bcc302f..6fdfbf27 100644 --- a/docs/api/cmd.rst +++ b/docs/api/cmd.rst @@ -65,26 +65,3 @@ cmd2.Cmd The symbol name which :ref:`features/scripting:Python Scripts` run using the :ref:`features/builtin_commands:run_pyscript` command can use to reference the parent ``cmd2`` application. - -.. autoclass:: cmd2.CompletionMode - - .. attribute:: NONE - - Tab completion will be disabled during read_input() call. Use of custom - up-arrow history supported. - - .. attribute:: COMMANDS - - read_input() will tab complete cmd2 commands and their arguments. - cmd2's command line history will be used for up arrow if history is not - provided. Otherwise use of custom up-arrow history supported. - - .. attribute:: CUSTOM - - read_input() will tab complete based on one of its following parameters - (choices, choices_provider, completer, parser). Use of custom up-arrow - history supported - -.. autoclass:: cmd2.cmd2.CustomCompletionSettings - - .. automethod:: __init__ \ No newline at end of file diff --git a/docs/api/utils.rst b/docs/api/utils.rst index 188f5b16..9276587f 100644 --- a/docs/api/utils.rst +++ b/docs/api/utils.rst @@ -36,6 +36,33 @@ IO Handling :members: +Tab Completion +-------------- + +.. autoclass:: cmd2.utils.CompletionMode + + .. attribute:: NONE + + Tab completion will be disabled during read_input() call. Use of custom + up-arrow history supported. + + .. attribute:: COMMANDS + + read_input() will tab complete cmd2 commands and their arguments. + cmd2's command line history will be used for up arrow if history is not + provided. Otherwise use of custom up-arrow history supported. + + .. attribute:: CUSTOM + + read_input() will tab complete based on one of its following parameters + (choices, choices_provider, completer, parser). Use of custom up-arrow + history supported + +.. autoclass:: cmd2.utils.CustomCompletionSettings + + .. automethod:: __init__ + + Text Alignment -------------- -- cgit v1.2.1 From 1a2095e5c373430e5aa4bda2ee24f65f4527a002 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Wed, 9 Sep 2020 01:26:08 -0400 Subject: Added section to completion docs about read_input() function --- docs/features/completion.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'docs') diff --git a/docs/features/completion.rst b/docs/features/completion.rst index 0e6bedd9..3894a4eb 100644 --- a/docs/features/completion.rst +++ b/docs/features/completion.rst @@ -89,6 +89,7 @@ completion hints. .. _argparse-based: + Tab Completion Using argparse Decorators ---------------------------------------- @@ -132,6 +133,17 @@ any of the 3 completion parameters: ``choices``, ``choices_provider``, and See the argparse_completion_ example or the implementation of the built-in :meth:`~cmd2.Cmd.do_set` command for demonstration of how this is used. + +Custom Completion with ``read_input()`` +-------------------------------------------------- + +``cmd2`` provides :attr:`cmd2.Cmd.read_input` as an alternative to Python's +``input()`` function. ``read_input`` supports configurable tab completion and +up-arrow history at the prompt. See read_input_ example for a demonstration. + +.. _read_input: https://github.com/python-cmd2/cmd2/blob/master/examples/read_input.py + + For More Information -------------------- -- cgit v1.2.1