summaryrefslogtreecommitdiff
path: root/tests/test_argparse.py
Commit message (Collapse)AuthorAgeFilesLines
* Fixing unit testsKevin Van Brunt2018-03-251-17/+11
|
* Fix unit tests on macOS when gnureadline is installedTodd Leonhardt2018-03-211-1/+12
| | | | As similar try/except needed to be added to a couple unit test files to try to import gnureadline as readline and fallback to importing readline.
* Fix unit tests and exampleTodd Leonhardt2018-03-161-4/+11
| | | | | | functools.partialmethod() was added in Python 3.4, so it can't be used in Python 2.7. - Modified the code to skip trying to use it for Python 2.7 - Skip the two unit tests which test its usage on Python 2.7
* Added unit tests and examples for tab completion of subcommandsKevin Van Brunt2018-03-161-5/+79
|
* No longer need to manually specify subcommand names for tab completionKevin Van Brunt2018-03-141-4/+1
|
* help command temporarily redirects sys.stdout and sys.stderr to self.stdout ↵Todd Leonhardt2018-01-221-26/+14
| | | | | | | | for argparse commands In order to make "help" behave more consistently for decorated and undecorated commands, argparse output is temporarily redirected to self.stdout. So doing "help history" is similar to "help load". However, when using the "-h" with argparse commands without using the "help" command, the output from argparse isn't redirected to self.stdout. Fixing this would be rather difficult and would essentially involve creating a pyparsing rule to detect it at the parser level.
* Renamed @with_argument_parser decorator to @with_argparserTodd Leonhardt2018-01-211-6/+6
| | | | | Also: - Reanamed foo and bar subcommand methods to base_foo and base_bar
* Added unit tests for sub-commandsTodd Leonhardt2018-01-201-0/+92
|
* Fixed unit testsTodd Leonhardt2018-01-201-6/+12
| | | | Updated unit tests due to changes in how help is output for commands decorated with an argparse ArgumentParser.
* Simplified a few argparse examples and fixed some incorrect documentationTodd Leonhardt2018-01-171-2/+2
| | | | | | I eliminated a few "narg=1" configurations so that a single str value is returned instead of a List[str]. I also reworded some documentation which was no longer correct after the last commit which made "history command" have the same help text as "command -h" when using one of the two argparse decorators.
* Improved how new argparse-based decorators provide helpTodd Leonhardt2018-01-171-1/+5
| | | | | | Now "help command_name" and "command_name -h" provide exactly the same text. The function docstring for the "do_*" command sets and overrides the ArgumentParser "description" if the docstring is not empty.
* Added a unit testTodd Leonhardt2018-01-151-0/+20
|
* Renamed new decorator to @with_argparser_and_unknown_args to make it more ↵Todd Leonhardt2018-01-151-1/+1
| | | | descriptive
* Changed @with_argument_parser to only pass single argument to commandsTodd Leonhardt2018-01-151-48/+26
| | | | Also added another @with_argparser_and_list decorator that uses argparse.parse_known_args to pass two arguments to a command: both the argparse output and a list of unknown/unmatched args.
* Made a couple cleanup changesTodd Leonhardt2018-01-151-19/+23
| | | | | | | | | 1) cmd2 no longer imports make_option from optparse - test files and examples now import this directly - this helps emphasize that this old optparse methodology of adding options to commands is deprecated 2) All argparsers have been given custom names instead of just "argparser" - this helps with readability and maintainability, especially with IDE renaming and such
* remove use_argument_list attributekotfu2018-01-141-34/+0
|
* Ensure help function works if use_argument_list = Truekotfu2018-01-141-3/+3
|
* more robust argparse and arglist decoratorskotfu2018-01-141-2/+44
|
* add use_argument_list settingkotfu2018-01-121-0/+21
| | | | new attribute on Cmd2.cmd which defaults to false, but if set true, causes all do_* commands to receive a list of arguments, instead of a string of what the user typed.
* new @with_argument_list decoratorkotfu2018-01-121-2/+13
|
* @with_argument_parser now passes an arglist instead of a stringkotfu2018-01-121-5/+16
|
* Fix a nasty bug in @with_argument_parserJared Crapo2018-01-101-0/+16
| | | | second argument of do_* methods was getting mangled when we strip quotes
* Set prog in argparser based on the name of the functionkotfu2018-01-071-7/+8
|
* Properly set docstring so it contains help messagekotfu2018-01-071-2/+10
|
* Add tests for POSIX=true and arguments containing spaceskotfu2018-01-071-3/+25
|
* Default posix and quote removal working.kotfu2018-01-071-15/+21
|
* New test cases for argparseJared Crapo2018-01-071-0/+54