summaryrefslogtreecommitdiff
path: root/examples/tab_autocompletion.py
Commit message (Collapse)AuthorAgeFilesLines
* Overhauling tab completion examplesKevin Van Brunt2020-02-121-268/+0
|
* Removed all instances where a parser's prog attribute was being set since ↵Kevin Van Brunt2019-10-301-1/+1
| | | | this is no longer needed
* Changed all uses of sub-command to subcommandKevin Van Brunt2019-07-191-2/+2
|
* Renamed ArgParser to Cmd2ArgumentParser to make it clear it's a derived ↵Kevin Van Brunt2019-07-181-3/+3
| | | | | | class of argparse.ArgumentParser when developers read the code in cmd2.py.
* Renamed Cmd2ArgParser to ArgParserKevin Van Brunt2019-07-121-3/+3
|
* More argparse completer unit testsKevin Van Brunt2019-07-071-6/+6
|
* Moved all custom argparse classes intended for normal development to ↵Kevin Van Brunt2019-07-071-3/+2
| | | | | | | argparse_custom.py. Lazy loading AutoCompleter in cmd2 instance methods to allow argparse_completer.py to import cmd2.Cmd class. This Architecture makes more sense because AutoCompleter depends on cmd2.Cmd.
* Fixed unit testsKevin Van Brunt2019-07-051-259/+0
|
* Fixing examplesKevin Van Brunt2019-07-041-39/+25
|
* Removed copyright headers from source files and updated LICENSE with current ↵Kevin Van Brunt2019-06-071-3/+0
| | | | year
* Refactor exit_code implementationTodd Leonhardt2019-05-201-1/+2
| | | | | | | | | | | | cmd2.Cmd.cmdloop() now returns self.exit_code which should be an integer Also: - Refactored examples to call sys.exit(app.cmdloop()) in their __main__ - Running transcript tests now sets the exit_code accordingly based on success/failure - Updated CHANGELOG - Updated README - Updated Sphinx docs - Added unit test for case when transcript test fails
* Improved code coverageKevin Van Brunt2019-05-071-1/+1
|
* Updated the examples to illustrate sorting CompletionItemsKevin Van Brunt2019-02-271-2/+5
|
* Made cmd2_app a positional and required argument of AutoCompleter.Kevin Van Brunt2019-02-231-1/+4
| | | | | Deleted bash tab completion support. AutoCompleter no longer assumes CompletionItem results are sorted.
* Fixed examplesKevin Van Brunt2019-02-081-2/+2
|
* Fix flake8 issuesTodd Leonhardt2018-12-061-21/+21
| | | | | | | | | | | | | | | | | | | | | | This commit contains a very large number of trivial changes in order to fix flake8 errors and warnings. Predominantly these are whitespace changes. Additionally, the build for Python 3.7 on TravisCI has been tweaked to fail if there are any flake8 errors using the following commandline: * flake8 . --count --ignore=E252 --max-complexity=31 --max-line-length=127 --show-source --statistics NOTE: In the future the max cyclomatic complexity should be lowered, but some improvements need to be made first. One flake8 error is being ignored entirely: * E252 missing whitespace around parameter equals * ignored because it doesn't correctly deal with default argument values after a type hint A few flake8 errors are being selectively ignored in certain files: * C901 fuction is too complex * ignored in argparse_completer.py because the complex code is an override of argparse complexity * E302 expected 2 blank lines after ... * ignored in all unit test files for convenience * F401 module imported but unused * ignored in cmd2/__init__.py because imports are for convenience of cmd2 developers and backwards compatibility * F821 undefined name * ignored in cmd2 script files which are intended to run only within cmd2 applications via pyscript where "app" and "cmd" are defined
* Added code to handle -- in argparse completerKevin Van Brunt2018-10-101-1/+1
|
* Merge remote-tracking branch 'origin/master' into argparse_remainderEric Lin2018-10-061-4/+4
|\
| * Using sub-command instead of subcommand where possible to be consistent with ↵Kevin Van Brunt2018-10-051-4/+4
| | | | | | | | argparse
* | Fixed a few edge cases:Eric Lin2018-10-061-0/+2
| | | | | | | | | | | | | | | | | | - Once the argument list can match a positional and that positional is tagged with nargs=argparse.REMAINDER it will consume all tokens including flag tokens. AutoCompleter now correctly detects this case will no longer attempt to complete flag tokens - A single-character token that is a flag prefix doesn't count as a flag and is parsed as a value. AutoCompleter now correctly detects this case.
* | Added handling of nargs=argparse.REMAINDER in both AutoCompleter and ↵Eric Lin2018-10-061-1/+1
|/ | | | | | | | ArgparseFunctor Should correctly force all subsequent arguments to go to the REMAINDER argument once it is detected. Re-arranged the command generation in ArgparseFunctor to print flag arguments before positionals Also forces the remainder arguments to always be last.
* ACHelpFormatter now inherits from argparse.RawTextHelpFormatter to make it ↵Kevin Van Brunt2018-08-241-7/+4
| | | | easier to format help/description text
* Updated argparse_completer to automatically set the matches_sorted flag for ↵Eric Lin2018-08-011-5/+7
| | | | tabular results. Updated the example to demonstrate pre-sorted tabular results.
* Added a check to verify the existence of a descriptive header. Added a ↵Eric Lin2018-06-131-3/+2
| | | | constant. Updated example to use the constant.
* Adds possible support for tabular tab completion results.Eric Lin2018-06-061-1/+17
|
* Fix import stragglerskotfu2018-05-231-2/+3
|
* Standardize cmd2 imports in tests and exampleskotfu2018-05-231-16/+15
|
* Changed some unit tests to use pytest-mock instead of mocker/monkeypatch ↵Eric Lin2018-05-191-3/+12
| | | | | | | because they were failing for me. Added detection of ==SUPPRESS== in subcommand group names to avoid printing it in the help hint. Added some examples to tab_autocompletion to demonstrate how to tie in to cmd2 path_complete
* Some fixes to autocompleter to make it easier to do delimited and file ↵Eric Lin2018-05-181-1/+19
| | | | completion. Saving state - more to come.
* Merge branch 'bash_completion' into bash_to_pyscriptEric Lin2018-05-021-2/+2
|\
| * Removed the expensive imports from cmd2/__init__.pyEric Lin2018-04-251-2/+2
| | | | | | | | | | | | | | Added some shared definitions to cmd2/__init__.py -> maybe there's a better place for these? Figured out how to trick bash into showing argument hints. It's a bit weird. Updated all of the tests and examples to import cmd2 resources from their new location without the automatic imports in cmd2/__init__.py For #369
* | Added support for customizing the pyscript bridge pystate object name.Eric Lin2018-05-021-0/+1
| | | | | | | | | | | | | | Removed all legacy pystate objects. Changed default behavior to clear _last_result before each command Added utility for creating named tuples with default values Added tests to exercise new changes.
* | Added more tests exercising the pyscript bridge.Eric Lin2018-04-301-0/+1
| |
* | Added support for translating function positional and keyword arguments into ↵Eric Lin2018-04-281-1/+1
|/ | | | | | argparse command positional and flag arguments. Added initial set of tests
* Added support for using cmd2 application class methods as an argument ↵Eric Lin2018-04-231-1/+5
| | | | completion provider. The default completion implementation in Cmd2 automatically passes self to AutoCompleter to be passed to the class method.
* Addressed PR comments. Simplified some of the implementation per PR comments.Eric Lin2018-04-231-111/+85
|
* Added some documentation related to the latest changes.Eric Lin2018-04-211-1/+9
|
* Changed cmd2 to use autocompleter by default for all argparse commands. Not ↵Eric Lin2018-04-201-9/+89
| | | | all tests are passing yet.
* Started adding type hintsTodd Leonhardt2018-04-191-2/+1
|
* Identified and marked a few blocks of code that can't be reached during unit ↵Eric Lin2018-04-191-1/+5
| | | | tests due to the lack of a real terminal. Some more comments.
* Addresses comments on #362Eric Lin2018-04-191-12/+12
|
* Merge remote-tracking branch 'origin/master' into autocompleterEric Lin2018-04-181-2/+1
| | | | | Updated AutoCompleter (#349) to match new directory structure from packaging effort.
* Some minor tweaks to AutoCompleter handling a collection of index-based ↵Eric Lin2018-04-171-1/+89
| | | | | | | | | function arguments. Added example for fully custom completion functions mixed with argparse/AutoCompleter handling - Also demonstrates the ability to pass in a list, tuple, or dict of parameters to append to the custom completion function. Added new test cases exercising the custom completion function calls. Added AutoCompleter and rl_utils to the coverage report.
* Added unit tests for AutoCompleter.Eric Lin2018-04-161-11/+8
|
* Added more advanced/complex autocompleter examples.Eric Lin2018-04-161-20/+174
| | | | Added more type hinting to AutoCompleter.
* Matched changes in the python3 branch.Eric Lin2018-04-151-1/+1
|
* * AutoCompleterEric Lin2018-04-151-8/+19
| | | | | | | | | - Fixed a few bugs in AutoCompleter dealing with nargs='+' or nargs='*' - Adjusted some help output dealing with narg ranges - Fixed spacing problem with printing argument help * examples/tab_autocompletion.py - Removed debug code. - Minor changes.
* Started working on an example for autocompleter usage.Eric Lin2018-04-141-0/+175