diff options
-rw-r--r-- | cmd2/decorators.py | 16 | ||||
-rw-r--r-- | docs/api/decorators.rst | 4 | ||||
-rw-r--r-- | docs/api/index.rst | 1 | ||||
-rw-r--r-- | docs/api/utility_classes.rst | 14 | ||||
-rw-r--r-- | docs/api/utility_functions.rst | 52 | ||||
-rw-r--r-- | docs/api/utils.rst | 5 | ||||
-rw-r--r-- | docs/features/completion.rst | 4 |
7 files changed, 23 insertions, 73 deletions
diff --git a/cmd2/decorators.py b/cmd2/decorators.py index 2c812345..f46e1423 100644 --- a/cmd2/decorators.py +++ b/cmd2/decorators.py @@ -31,12 +31,22 @@ def with_category(category: str) -> Callable: def with_argument_list(*args: List[Callable], preserve_quotes: bool = False) -> Callable[[List], Optional[bool]]: - """A decorator to alter the arguments passed to a do_* cmd2 method. Default passes a string of whatever the user - typed. With this decorator, the decorated method will receive a list of arguments parsed from user input. + """ + A decorator to alter the arguments passed to a ``do_*`` method. Default + passes a string of whatever the user typed. With this decorator, the + decorated method will receive a list of arguments parsed from user input. - :param args: Single-element positional argument list containing do_* method this decorator is wrapping + :param args: Single-element positional argument list containing do_* method + this decorator is wrapping :param preserve_quotes: if True, then argument quotes will not be stripped :return: function that gets passed a list of argument strings + + :Example: + + >>> class MyApp(cmd2.Cmd): + >>> @cmd2.with_argument_list + >>> def do_echo(self, arglist): + >>> self.poutput(' '.join(arglist) """ import functools diff --git a/docs/api/decorators.rst b/docs/api/decorators.rst index 12ab62fa..e5ca4c7e 100644 --- a/docs/api/decorators.rst +++ b/docs/api/decorators.rst @@ -1,5 +1,5 @@ -Decorators -========== +cmd2.decorators +=============== .. autofunction:: cmd2.decorators.with_argparser diff --git a/docs/api/index.rst b/docs/api/index.rst index f0324eab..4781a249 100644 --- a/docs/api/index.rst +++ b/docs/api/index.rst @@ -8,5 +8,6 @@ API Reference decorators exceptions ansi + utils utility_classes utility_functions diff --git a/docs/api/utility_classes.rst b/docs/api/utility_classes.rst index 2ee92ced..99a714ee 100644 --- a/docs/api/utility_classes.rst +++ b/docs/api/utility_classes.rst @@ -1,16 +1,2 @@ Utility Classes =============== - -.. autoclass:: cmd2.utils.Settable - - .. automethod:: __init__ - -.. autoclass:: cmd2.utils.StdSim - -.. autoclass:: cmd2.utils.ByteBuf - -.. autoclass:: cmd2.utils.ProcReader - -.. autoclass:: cmd2.utils.ContextFlag - -.. autoclass:: cmd2.utils.RedirectionSavedState diff --git a/docs/api/utility_functions.rst b/docs/api/utility_functions.rst index 4f788e3d..0fe6b341 100644 --- a/docs/api/utility_functions.rst +++ b/docs/api/utility_functions.rst @@ -1,54 +1,2 @@ Utility Functions ================= - -.. autofunction:: cmd2.utils.is_quoted - -.. autofunction:: cmd2.utils.quote_string_if_needed - -.. autofunction:: cmd2.utils.strip_quotes - -.. autofunction:: cmd2.decorators.categorize - -.. autofunction:: cmd2.utils.align_text - -.. autofunction:: cmd2.utils.align_left - -.. autofunction:: cmd2.utils.align_center - -.. autofunction:: cmd2.utils.align_right - -.. autofunction:: cmd2.utils.truncate_line - -.. autofunction:: cmd2.utils.strip_quotes - -.. autofunction:: cmd2.utils.namedtuple_with_defaults - -.. autofunction:: cmd2.utils.which - -.. autofunction:: cmd2.utils.is_text_file - -.. autofunction:: cmd2.utils.remove_duplicates - -.. autofunction:: cmd2.utils.norm_fold - -.. autofunction:: cmd2.utils.try_int_or_force_to_lower_case - -.. autofunction:: cmd2.utils.alphabetical_sort - -.. autofunction:: cmd2.utils.unquote_specific_tokens - -.. autofunction:: cmd2.utils.natural_sort - -.. autofunction:: cmd2.utils.natural_keys - -.. autofunction:: cmd2.utils.expand_user_in_tokens - -.. autofunction:: cmd2.utils.expand_user - -.. autofunction:: cmd2.utils.find_editor - -.. autofunction:: cmd2.utils.get_exes_in_path - -.. autofunction:: cmd2.utils.files_from_glob_patterns - -.. autofunction:: cmd2.utils.files_from_glob_pattern diff --git a/docs/api/utils.rst b/docs/api/utils.rst new file mode 100644 index 00000000..8019b379 --- /dev/null +++ b/docs/api/utils.rst @@ -0,0 +1,5 @@ +cmd2.utils +========== + +.. automodule:: cmd2.utils + :members: diff --git a/docs/features/completion.rst b/docs/features/completion.rst index 14a98caf..c8b0a813 100644 --- a/docs/features/completion.rst +++ b/docs/features/completion.rst @@ -36,8 +36,8 @@ similar to the following to your class which inherits from ``cmd2.Cmd``:: Tab Completion Using Argparse Decorators ---------------------------------------- -When using one the Argparse-based :ref:`api/decorators:Decorators`, ``cmd2`` -provides automatic tab-completion of flag names. +When using one the Argparse-based :ref:`api/decorators:cmd2.decorators`, +``cmd2`` provides automatic tab-completion of flag names. Tab-completion of argument values can be configured by using one of five parameters to ``argparse.ArgumentParser.add_argument()`` |