summaryrefslogtreecommitdiff
path: root/cmd2.py
Commit message (Collapse)AuthorAgeFilesLines
* Fixed issue with automated transcript generation via "history -t"Todd Leonhardt2018-01-291-0/+7
| | | | There is now a post-processing step which escapes all "/" characters which transcript testing treats as a regex escape if there isn't a "\" to esape it.
* redirect_stderr wasn't added to contextlib until Python 3.5Todd Leonhardt2018-01-221-4/+6
| | | | So it turns out that we need contextlib2 for Python 3.4 and earlier.
* help command temporarily redirects sys.stdout and sys.stderr to self.stdout ↵Todd Leonhardt2018-01-221-11/+23
| | | | | | | | 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-3/+3
| | | | | Also: - Reanamed foo and bar subcommand methods to base_foo and base_bar
* History enhancementsTodd Leonhardt2018-01-201-6/+37
| | | | | | | | | | History changes: - Unknown commands are no longer saved in the history - history command now has a -t option to generate a transcript based on commands in the history Also: - Moved examples transcripts from examples to examples/transcripts - Added a new transcript for use with the pirate.py example
* Added unit tests for newly-overridden complete() methodTodd Leonhardt2018-01-201-0/+8
| | | | Also added a section on Sub-commands to the documentation.
* Added unit tests for sub-commandsTodd Leonhardt2018-01-201-1/+1
|
* Tab-completion of subcommand names is now supportedTodd Leonhardt2018-01-201-9/+99
|
* Added links to docs and examples to CHANGELOG.mdTodd Leonhardt2018-01-201-1/+1
| | | | Also bumped version to 0.8.0.
* Added support for argparse sub-commands when using cmd2 decoratorsTodd Leonhardt2018-01-201-2/+20
| | | | | | | | | | | Modified the do_help() method to behave differently for methods which have been decorated with an argparse ArgumentParser. This is so that help will properly deal with sub-command help. Suppose you have a base command "base" which has two sub-commands, "foo" and "bar". Then "help base" will provide very different help text than "help base foo". Slightly tweaked the two argparse decorators to set an attribute in the decorated function's dictionary so that the do_help method can know which functions have an ArgumentParser and which do not. Added a "subcommands.py" example for demonstrating how to create and use subcommands based on argparse and the cmd2 @with_argument_parser decorator.
* Improved how new argparse-based decorators provide helpTodd Leonhardt2018-01-171-30/+21
| | | | | | 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.
* Cleanup of documentation and examplesTodd Leonhardt2018-01-171-1/+0
| | | | Removed usage of and reference to attributes and commands which have now been removed.
* Fix bug which prevented multiple history commands from being runkotfu2018-01-161-1/+1
|
* do_edit() no longer edits history, just files #252kotfu2018-01-161-77/+5
|
* Remove do_save() and do_run() for #252kotfu2018-01-161-60/+8
|
* Implement -o, -r, and -e options for issue #252Jared Crapo2018-01-151-10/+42
|
* cmdenvironment command has been removed and its functionality now exists as ↵Todd Leonhardt2018-01-151-16/+25
| | | | a -a/--all option to the set command
* show command has been removedTodd Leonhardt2018-01-151-13/+17
| | | | | | It's functionality has been moved inside the set command. The set command now uses an argparse parser.
* __relative_load command is now hidden from help menu by defaultTodd Leonhardt2018-01-151-1/+1
|
* Argument parsing and support currention functionality for #252kotfu2018-01-151-12/+16
| | | | still need to add support for -o, -r, and -e options.
* 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-20/+46
| | | | 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.
* Just improved a few comments which had become outdatedTodd Leonhardt2018-01-151-5/+6
|
* Replaced @options decorator with @with_argument_list for do_editTodd Leonhardt2018-01-151-7/+11
|
* Made a couple cleanup changesTodd Leonhardt2018-01-151-12/+11
| | | | | | | | | 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
* Merge branch 'arglist' of github.com:python-cmd2/cmd2 into arglistkotfu2018-01-141-1/+5
|\
| * Fixed do_history unit tests and implementationTodd Leonhardt2018-01-151-1/+1
| |
| * Fixed @with_argument_decorator so that built-in help text is preservedTodd Leonhardt2018-01-151-0/+4
| |
* | convert do_pyscript() to use @with_argument_listkotfu2018-01-141-9/+5
| |
* | convert do_show() to argparsekotfu2018-01-141-12/+9
|/
* convert do_history() to argparsekotfu2018-01-141-20/+16
|
* remove use_argument_list attributekotfu2018-01-141-6/+2
|
* refactor onecmd() to use parse_quoted_string()kotfu2018-01-141-7/+1
|
* Convert built-in commands to argparsing for #250kotfu2018-01-141-13/+17
| | | | | | | | | | | | | This commit converts the following methods: - do_eos() - do_eof() - do_quit() - do_shortcuts() - do_cmdenvironment() - do__relative_load() - do_load() - do_help()
* more robust argparse and arglist decoratorskotfu2018-01-141-16/+18
|
* add use_argument_list settingkotfu2018-01-121-1/+13
| | | | 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-0/+18
|
* @with_argument_parser now passes an arglist instead of a stringkotfu2018-01-121-1/+1
|
* Fix a nasty bug in @with_argument_parserJared Crapo2018-01-101-3/+3
| | | | 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-1/+5
|
* Properly set docstring so it contains help messagekotfu2018-01-071-1/+9
|
* Remove leftover debugging codekotfu2018-01-071-2/+0
|
* Merge branch 'master' of github.com:python-cmd2/cmd2 into argparsekotfu2018-01-071-5/+5
|\
| * Enabled Python 3.7 testing on Travis CITodd Leonhardt2018-01-061-5/+5
| | | | | | | | Also bumped version to 0.8.0a
* | Default posix and quote removal working.kotfu2018-01-071-12/+10
| |
* | Merge branch 'master' of github.com:python-cmd2/cmd2 into argparsekotfu2018-01-071-12/+28
|\ \ | |/
| * Fix test_transcript.py in python 3.7kotfu2018-01-061-1/+16
| | | | | | | | re.escape() changed behavior in python 3.7.
| * Updating version and changelog in preparation for minor bug fix realeaseTodd Leonhardt2018-01-041-11/+12
| |
* | New test cases for argparseJared Crapo2018-01-071-2/+14
| |
* | Merge branch 'master' of https://github.com/python-cmd2/cmd2 into argparseJared Crapo2017-12-111-4/+15
|\ \ | |/