diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-02-13 13:39:53 -0500 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-02-13 13:39:53 -0500 |
commit | 41019de4b55f42d17149c29d380358dc38347948 (patch) | |
tree | 896f769ab1d919132b51ee0dbf7006cf07f87961 | |
parent | c3e3c1c595d65ec4c5fa2c9dac88ffa30cf4738e (diff) | |
download | cmd2-git-41019de4b55f42d17149c29d380358dc38347948.tar.gz |
Removed dash from 'tab complete' string
-rw-r--r-- | CHANGELOG.md | 28 | ||||
-rwxr-xr-x | README.md | 12 | ||||
-rw-r--r-- | cmd2/argparse_custom.py | 14 | ||||
-rw-r--r-- | docs/features/argument_processing.rst | 2 | ||||
-rw-r--r-- | docs/features/completion.rst | 14 | ||||
-rw-r--r-- | docs/features/embedded_python_shells.rst | 2 | ||||
-rw-r--r-- | docs/features/initialization.rst | 2 | ||||
-rw-r--r-- | docs/features/os.rst | 2 | ||||
-rw-r--r-- | docs/features/scripting.rst | 4 | ||||
-rw-r--r-- | docs/features/settings.rst | 4 | ||||
-rw-r--r-- | docs/overview/installation.rst | 2 | ||||
-rwxr-xr-x | examples/basic_completion.py | 12 | ||||
-rw-r--r-- | tests/conftest.py | 2 | ||||
-rwxr-xr-x | tests/test_completion.py | 14 |
14 files changed, 57 insertions, 57 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d4e3bc0b..f9d71831 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ ## 0.10.0 (February 7, 2020) * Enhancements * Changed the default help text to make `help -v` more discoverable - * **set** command now supports tab-completion of values + * **set** command now supports tab completion of values * Added `add_settable()` and `remove_settable()` convenience methods to update `self.settable` dictionary * Added convenience `ansi.fg` and `ansi.bg` enums of foreground and background colors * `ansi.style()` `fg` argument can now either be of type `str` or `ansi.fg` @@ -185,7 +185,7 @@ `delimiter_complete`, `flag_based_complete`, `index_based_complete`, `path_complete`, `shell_cmd_complete` * Renamed history option from `--output-file` to `--output_file` * Renamed `matches_sort_key` to `default_sort_key`. This value determines the default sort ordering of string - results like alias, command, category, macro, settable, and shortcut names. Unsorted tab-completion results + results like alias, command, category, macro, settable, and shortcut names. Unsorted tab completion results also are sorted with this key. Its default value (ALPHABETICAL_SORT_KEY) performs a case-insensitive alphabetical sort, but it can be changed to a natural sort by setting the value to NATURAL_SORT_KEY. * `StatementParser` now expects shortcuts to be passed in as dictionary. This eliminates the step of converting the @@ -434,7 +434,7 @@ * ``ACHelpFormatter`` now inherits from ``argparse.RawTextHelpFormatter`` to make it easier for formatting help/description text * Aliases are now sorted alphabetically - * The **set** command now tab-completes settable parameter names + * The **set** command now tab completes settable parameter names * Added ``async_alert``, ``async_update_prompt``, and ``set_window_title`` functions * These allow you to provide feedback to the user in an asychronous fashion, meaning alerts can display when the user is still entering text at the prompt. See [async_printing.py](https://github.com/python-cmd2/cmd2/blob/master/examples/async_printing.py) @@ -468,7 +468,7 @@ * Improved implementation of lifecycle hooks to support a plugin framework, see ``docs/hooks.rst`` for details. * New dependency on ``attrs`` third party module - * Added ``matches_sorted`` member to support custom sorting of tab-completion matches + * Added ``matches_sorted`` member to support custom sorting of tab completion matches * Added [tab_autocomp_dynamic.py](https://github.com/python-cmd2/cmd2/blob/master/examples/tab_autocomp_dynamic.py) example * Demonstrates updating the argparse object during init instead of during class construction * Deprecations @@ -498,7 +498,7 @@ * Bug Fixes * Fixed issue where piping and redirecting did not work correctly with paths that had spaces * Enhancements - * Added ability to print a header above tab-completion suggestions using `completion_header` member + * Added ability to print a header above tab completion suggestions using `completion_header` member * Added ``pager`` and ``pager_chop`` attributes to the ``cmd2.Cmd`` class * ``pager`` defaults to **less -RXF** on POSIX and **more** on Windows * ``pager_chop`` defaults to **less -SRXF** on POSIX and **more** on Windows @@ -570,7 +570,7 @@ * Fixed ``AttributeError`` on Windows when running a ``select`` command cause by **pyreadline** not implementing ``remove_history_item`` * Enhancements * Added warning about **libedit** variant of **readline** not being supported on macOS - * Added tab-completion of alias names in value field of **alias** command + * Added tab completion of alias names in value field of **alias** command * Enhanced the ``py`` console in the following ways * Added tab completion of Python identifiers instead of **cmd2** commands * Separated the ``py`` console history from the **cmd2** history @@ -628,7 +628,7 @@ ## 0.8.2 (March 21, 2018) * Bug Fixes - * Fixed a bug in tab-completion of command names within sub-menus + * Fixed a bug in tab completion of command names within sub-menus * Fixed a bug when using persistent readline history in Python 2.7 * Fixed a bug where the ``AddSubmenu`` decorator didn't work with a default value for ``shared_attributes`` * Added a check to ``ppaged()`` to only use a pager when running in a real fully functional terminal @@ -685,7 +685,7 @@ and [arg_print.py](https://github.com/python-cmd2/cmd2/blob/master/examples/arg_print.py) examples * Added support for Argparse subcommands when using the **with_argument_parser** or **with_argparser_and_unknown_args** decorators * See [subcommands.py](https://github.com/python-cmd2/cmd2/blob/master/examples/subcommands.py) for an example of how to use subcommands - * Tab-completion of subcommand names is automatically supported + * Tab completion of subcommand names is automatically supported * The **__relative_load** command is now hidden from the help menu by default * This command is not intended to be called from the command line, only from within scripts * The **set** command now has an additional **-a/--all** option to also display read-only settings @@ -712,7 +712,7 @@ * Fixed a couple broken examples * Enhancements * Improved documentation for modifying shortcuts (command aliases) - * Made ``pyreadline`` a dependency on Windows to ensure tab-completion works + * Made ``pyreadline`` a dependency on Windows to ensure tab completion works * Other changes * Abandoned official support for Python 3.3. It should still work, just don't have an easy way to test it anymore. @@ -750,7 +750,7 @@ * Fixed some pyperclip clipboard interaction bugs on Linux * Fixed some timing bugs when running unit tests in parallel by using monkeypatch * Enhancements - * Enhanced tab-completion of cmd2 command names to support case-insensitive completion + * Enhanced tab completion of cmd2 command names to support case-insensitive completion * Added an example showing how to remove unused commands * Improved how transcript testing handles prompts with ANSI escape codes by stripping them * Greatly improved implementation for how command output gets piped to a shell command @@ -766,7 +766,7 @@ * Enhancements * Organized all attributes used to configure the ParserManager into a single location * Set the default value of `abbrev` to `False` (which controls whether or not abbreviated commands are allowed) - * With good tab-completion of command names, using abbreviated commands isn't particularly useful + * With good tab completion of command names, using abbreviated commands isn't particularly useful * And it can create complications if you are't careful * Improved implementation of `load` to use command queue instead of nested inner loop @@ -778,7 +778,7 @@ * Ability to pipe ``cmd2`` command output to a shell command is now more reliable, particularly on Windows * Fixed a bug in ``pyscript`` command on Windows related to ``\`` being interpreted as an escape * Enhancements - * Ensure that path and shell command tab-completion results are alphabetically sorted + * Ensure that path and shell command tab completion results are alphabetically sorted * Removed feature for load command to load scripts from URLS * It didn't work, there were no unit tests, and it felt out of place * Removed presence of a default file name and default file extension @@ -801,8 +801,8 @@ * Enhancements * Added the ability to exclude commands from the help menu (**eof** included by default) * Redundant **list** command removed and features merged into **history** command - * Added **pyscript** command which supports tab-completion and running Python scripts with arguments - * Improved tab-completion of file system paths, command names, and shell commands + * Added **pyscript** command which supports tab completion and running Python scripts with arguments + * Improved tab completion of file system paths, command names, and shell commands * Thanks to Kevin Van Brunt for all of the help with debugging and testing this * Changed default value of USE_ARG_LIST to True - this affects the beavhior of all **@options** commands * **WARNING**: This breaks backwards compatibility, to restore backwards compatibility, add this to the @@ -37,8 +37,8 @@ Main Features - Settable environment parameters - Parsing commands with arguments using `argparse`, including support for subcommands - Unicode character support -- Good tab-completion of commands, subcommands, file system paths, and shell commands -- Automatic tab-completion of `argparse` flags when using one of the `cmd2` `argparse` decorators +- Good tab completion of commands, subcommands, file system paths, and shell commands +- Automatic tab completion of `argparse` flags when using one of the `cmd2` `argparse` decorators - Support for Python 3.5+ on Windows, macOS, and Linux - Trivial to provide built-in help for all commands - Built-in regression testing framework for your applications (transcript-based testing) @@ -96,7 +96,7 @@ Instructions for implementing each feature follow. - By default the docstring for your **do_foo** method is the help for the **foo** command - NOTE: This doesn't apply if you use one of the `argparse` decorators mentioned below - Can provide more custom help by creating a **help_foo** method (except when using `argparse` decorators) - - Can provide custom tab-completion for the **foo** command by creating a **complete_foo** method + - Can provide custom tab completion for the **foo** command by creating a **complete_foo** method - Easy to upgrade an existing `cmd` app to `cmd2` - Run your `cmd2` app using the built-in REPL by executing the **cmdloop** method @@ -164,14 +164,14 @@ Instructions for implementing each feature follow. - Option to display long output using a pager with ``cmd2.Cmd.ppaged()`` - Optionally specify a startup script that end users can use to customize their environment -- Top-notch tab-completion capabilities which are easy to use but very powerful +- Top-notch tab completion capabilities which are easy to use but very powerful - For a command **foo** implement a **complete_foo** method to provide custom tab completion for that command - But the helper methods within `cmd2` discussed below mean you would rarely have to implement this from scratch - - Commands which use one of the `argparse` decorators have automatic tab-completion of `argparse` flags + - Commands which use one of the `argparse` decorators have automatic tab completion of `argparse` flags - And also provide help hints for values associated with these flags - Experiment with the [argprint.py](https://github.com/python-cmd2/cmd2/blob/master/examples/arg_print.py) example using the **oprint** and **pprint** commands to get a feel for how this works - - `path_complete` helper method provides flexible tab-completion of file system paths + - `path_complete` helper method provides flexible tab completion of file system paths - See the [paged_output.py](https://github.com/python-cmd2/cmd2/blob/master/examples/paged_output.py) example for a simple use case - See the [python_scripting.py](https://github.com/python-cmd2/cmd2/blob/master/examples/python_scripting.py) example for a more full-featured use case - `flag_based_complete` helper method for tab completion based on a particular flag preceding the token being completed diff --git a/cmd2/argparse_custom.py b/cmd2/argparse_custom.py index a0e05ae9..a59270c3 100644 --- a/cmd2/argparse_custom.py +++ b/cmd2/argparse_custom.py @@ -62,8 +62,8 @@ Tab Completion: return my_generated_list completer_function - Pass a tab-completion function that does custom completion. Since custom tab completion operations commonly - need to modify cmd2's instance variables related to tab-completion, it will be rare to need a completer + Pass a tab completion function that does custom completion. Since custom tab completion operations commonly + need to modify cmd2's instance variables related to tab completion, it will be rare to need a completer function. completer_method should be used in those cases. Example: @@ -90,7 +90,7 @@ Tab Completion: path_filter=lambda path: os.path.isdir(path)) parser.add_argument('-o', '--options', choices_method=completer_method) - Of the 5 tab-completion parameters, choices is the only one where argparse validates user input against items + Of the 5 tab completion parameters, choices is the only one where argparse validates user input against items in the choices list. This is because the other 4 parameters are meant to tab complete data sets that are viewed as dynamic. Therefore it is up to the developer to validate if the user has typed an acceptable value for these arguments. @@ -118,7 +118,7 @@ Tab Completion: the developer to determine if the user entered the correct argument type (e.g. int) and validate their values. CompletionError Class: - Raised during tab-completion operations to report any sort of error you want printed by the AutoCompleter + Raised during tab completion operations to report any sort of error you want printed by the AutoCompleter Example use cases - Reading a database to retrieve a tab completion data set failed @@ -231,7 +231,7 @@ def generate_range_error(range_min: int, range_max: Union[int, float]) -> str: class CompletionError(Exception): """ - Raised during tab-completion operations to report any sort of error you want printed by the AutoCompleter + Raised during tab completion operations to report any sort of error you want printed by the AutoCompleter Example use cases - Reading a database to retrieve a tab completion data set failed @@ -356,8 +356,8 @@ def _add_argument_wrapper(self, *args, # Added args used by AutoCompleter :param choices_function: function that provides choices for this argument :param choices_method: cmd2-app method that provides choices for this argument - :param completer_function: tab-completion function that provides choices for this argument - :param completer_method: cmd2-app tab-completion method that provides choices for this argument + :param completer_function: tab completion function that provides choices for this argument + :param completer_method: cmd2-app tab completion method that provides choices for this argument :param suppress_tab_hint: when AutoCompleter has no results to show during tab completion, it displays the current argument's help text as a hint. Set this to True to suppress the hint. If this argument's help text is set to argparse.SUPPRESS, then tab hints will not display regardless of the diff --git a/docs/features/argument_processing.rst b/docs/features/argument_processing.rst index 39a39804..82244d7e 100644 --- a/docs/features/argument_processing.rst +++ b/docs/features/argument_processing.rst @@ -325,7 +325,7 @@ Subcommands are supported for commands using either the ``@with_argparser`` or is based on argparse sub-parsers. You may add multiple layers of subcommands for your command. ``cmd2`` will -automatically traverse and tab-complete subcommands for all commands using +automatically traverse and tab complete subcommands for all commands using argparse. See the subcommands_ example to learn more about how to diff --git a/docs/features/completion.rst b/docs/features/completion.rst index 9103b543..a8c1cc85 100644 --- a/docs/features/completion.rst +++ b/docs/features/completion.rst @@ -1,7 +1,7 @@ Completion ========== -``cmd2`` adds tab-completion of file system paths for all built-in commands +``cmd2`` adds tab completion of file system paths for all built-in commands where it makes sense, including: - ``edit`` @@ -9,7 +9,7 @@ where it makes sense, including: - ``run_script`` - ``shell`` -``cmd2`` also adds tab-completion of shell commands to the ``shell`` command. +``cmd2`` also adds tab completion of shell commands to the ``shell`` command. Additionally, it is trivial to add identical file system path completion to your own custom commands. Suppose you have defined a custom command ``foo`` by @@ -37,9 +37,9 @@ Tab Completion Using Argparse Decorators ---------------------------------------- When using one the Argparse-based :ref:`api/decorators:Decorators`, ``cmd2`` -provides automatic tab-completion of flag names. +provides automatic tab completion of flag names. -Tab-completion of argument values can be configured by using one of five +Tab completion of argument values can be configured by using one of five parameters to ``argparse.ArgumentParser.add_argument()`` - ``choices`` @@ -52,9 +52,9 @@ demonstration of how to use the ``choices_function`` and ``choices_method`` parameters. See the arg_decorators_ or argparse_completion_ example for a demonstration of how to use the ``completer_method`` parameter. -When tab-completing flags and/or argument values for a ``cmd2`` command using +When tab completing flags and/or argument values for a ``cmd2`` command using one of these decorators, ``cmd2`` keeps track of state so that once a flag has -already previously been provided, it won't attempt to tab-complete it again. +already previously been provided, it won't attempt to tab complete it again. When no completion results exists, a hint for the current argument will be displayed to help the user. @@ -66,7 +66,7 @@ displayed to help the user. CompletionItem For Providing Extra Context ------------------------------------------ -When tab-completing things like a unique ID from a database, it can often be +When tab completing things like a unique ID from a database, it can often be beneficial to provide the user with some extra context about the item being completed, such as a description. To facilitate this, ``cmd2`` defines the ``CompletionItem`` class which can be returned from any of the 4 completion diff --git a/docs/features/embedded_python_shells.rst b/docs/features/embedded_python_shells.rst index 68377876..70765b21 100644 --- a/docs/features/embedded_python_shells.rst +++ b/docs/features/embedded_python_shells.rst @@ -67,7 +67,7 @@ code directory for an example of how to achieve this in your own applications. Using ``py`` to run scripts directly is considered deprecated. The newer ``run_pyscript`` command is superior for doing this in two primary ways: -- it supports tab-completion of file system paths +- it supports tab completion of file system paths - it has the ability to pass command-line arguments to the scripts invoked There are no disadvantages to using ``run_pyscript`` as opposed to ``py diff --git a/docs/features/initialization.rst b/docs/features/initialization.rst index 6824c7bf..b1ca4f05 100644 --- a/docs/features/initialization.rst +++ b/docs/features/initialization.rst @@ -133,7 +133,7 @@ override: command via ``self`` (Default: ``False``) - **macros**: dictionary of macro names and their values - **max_completion_items**: max number of CompletionItems to display during - tab-completion (Default: 50) + tab completion (Default: 50) - **pager**: sets the pager command used by the ``Cmd.ppaged()`` method for displaying wrapped output using a pager - **pager_chop**: sets the pager command used by the ``Cmd.ppaged()`` method diff --git a/docs/features/os.rst b/docs/features/os.rst index 89905d17..77bc6a66 100644 --- a/docs/features/os.rst +++ b/docs/features/os.rst @@ -20,7 +20,7 @@ to type:: (Cmd) !ls -al -NOTE: ``cmd2`` provides user-friendly tab-completion throughout the process of +NOTE: ``cmd2`` provides user-friendly tab completion throughout the process of running a shell command - first for the shell command name itself, and then for file paths in the argument section. diff --git a/docs/features/scripting.rst b/docs/features/scripting.rst index 62af2e6d..1128f5e1 100644 --- a/docs/features/scripting.rst +++ b/docs/features/scripting.rst @@ -34,7 +34,7 @@ Running Command Scripts Command script files can be executed using the built-in ``run_script`` command or ``@`` shortcut. Both ASCII and UTF-8 encoded unicode text files are -supported. The ``run_script`` command supports tab-completion of file system +supported. The ``run_script`` command supports tab completion of file system paths. There is a variant ``_relative_run_script`` command or ``@@`` shortcut for use within a script which uses paths relative to the first script. @@ -73,7 +73,7 @@ using ``run_pyscript`` is shown below along with the arg_printer_ script:: arg 2: 'bar' arg 3: 'baz 23' -``run_pyscript`` supports tab-completion of file system paths, and as shown +``run_pyscript`` supports tab completion of file system paths, and as shown above it has the ability to pass command-line arguments to the scripts invoked. Python scripts executed with ``run_pyscript`` can run ``cmd2`` application diff --git a/docs/features/settings.rst b/docs/features/settings.rst index 5a4a9c0f..aa3e5cec 100644 --- a/docs/features/settings.rst +++ b/docs/features/settings.rst @@ -89,11 +89,11 @@ max_completion_items ~~~~~~~~~~~~~~~~~~~~ Maximum number of CompletionItems to display during tab completion. A -CompletionItem is a special kind of tab-completion hint which displays both a +CompletionItem is a special kind of tab completion hint which displays both a value and description and uses one line for each hint. Tab complete the ``set`` command for an example. -If the number of tab-completion hints exceeds ``max_completion_items``, then +If the number of tab completion hints exceeds ``max_completion_items``, then they will be displayed in the typical columnized format and will not include the description text of the CompletionItem. diff --git a/docs/overview/installation.rst b/docs/overview/installation.rst index d8d24ebd..6080fe90 100644 --- a/docs/overview/installation.rst +++ b/docs/overview/installation.rst @@ -119,7 +119,7 @@ macOS Considerations -------------------- macOS comes with the `libedit <http://thrysoee.dk/editline/>`_ library which is -similar, but not identical, to GNU Readline. Tab-completion for ``cmd2`` +similar, but not identical, to GNU Readline. Tab completion for ``cmd2`` applications is only tested against GNU Readline. There are several ways GNU Readline can be installed within a Python diff --git a/examples/basic_completion.py b/examples/basic_completion.py index 3750c2c6..f21f75fc 100755 --- a/examples/basic_completion.py +++ b/examples/basic_completion.py @@ -44,15 +44,15 @@ class BasicCompletion(cmd2.Cmd): """Completion function for do_flag_based""" flag_dict = \ { - # Tab-complete food items after -f and --food flags in command line + # Tab complete food items after -f and --food flags in command line '-f': food_item_strs, '--food': food_item_strs, - # Tab-complete sport items after -s and --sport flags in command line + # Tab complete sport items after -s and --sport flags in command line '-s': sport_item_strs, '--sport': sport_item_strs, - # Tab-complete using path_complete function after -p and --path flags in command line + # Tab complete using path_complete function after -p and --path flags in command line '-p': self.path_complete, '--path': self.path_complete, } @@ -67,9 +67,9 @@ class BasicCompletion(cmd2.Cmd): """Completion function for do_index_based""" index_dict = \ { - 1: food_item_strs, # Tab-complete food items at index 1 in command line - 2: sport_item_strs, # Tab-complete sport items at index 2 in command line - 3: self.path_complete, # Tab-complete using path_complete function at index 3 in command line + 1: food_item_strs, # Tab complete food items at index 1 in command line + 2: sport_item_strs, # Tab complete sport items at index 2 in command line + 3: self.path_complete, # Tab complete using path_complete function at index 3 in command line } return self.index_based_complete(text, line, begidx, endidx, index_dict=index_dict) diff --git a/tests/conftest.py b/tests/conftest.py index 7f77a207..9ee8da19 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -185,7 +185,7 @@ def complete_tester(text: str, line: str, begidx: int, endidx: int, app) -> Opti def get_endidx(): return endidx - # Run the readline tab-completion function with readline mocks in place + # Run the readline tab completion function with readline mocks in place with mock.patch.object(readline, 'get_line_buffer', get_line): with mock.patch.object(readline, 'get_begidx', get_begidx): with mock.patch.object(readline, 'get_endidx', get_endidx): diff --git a/tests/test_completion.py b/tests/test_completion.py index 99f832a4..f545c8f9 100755 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -1,9 +1,9 @@ # coding=utf-8 # flake8: noqa E302 """ -Unit/functional testing for readline tab-completion functions in the cmd2.py module. +Unit/functional testing for readline tab completion functions in the cmd2.py module. -These are primarily tests related to readline completer functions which handle tab-completion of cmd2/cmd commands, +These are primarily tests related to readline completer functions which handle tab completion of cmd2/cmd commands, file system paths, and shell commands. """ # Python 3.5 had some regressions in the unitest.mock module, so use 3rd party mock if available @@ -39,11 +39,11 @@ delimited_strs = \ # Dictionary used with flag based completion functions flag_dict = \ { - # Tab-complete food items after -f and --food flag in command line + # Tab complete food items after -f and --food flag in command line '-f': food_item_strs, '--food': food_item_strs, - # Tab-complete sport items after -s and --sport flag in command line + # Tab complete sport items after -s and --sport flag in command line '-s': sport_item_strs, '--sport': sport_item_strs, } @@ -51,14 +51,14 @@ flag_dict = \ # Dictionary used with index based completion functions index_dict = \ { - 1: food_item_strs, # Tab-complete food items at index 1 in command line - 2: sport_item_strs, # Tab-complete sport items at index 2 in command line + 1: food_item_strs, # Tab complete food items at index 1 in command line + 2: sport_item_strs, # Tab complete sport items at index 2 in command line } class CompletionsExample(cmd2.Cmd): """ - Example cmd2 application used to exercise tab-completion tests + Example cmd2 application used to exercise tab completion tests """ def __init__(self): cmd2.Cmd.__init__(self, multiline_commands=['test_multiline']) |