summaryrefslogtreecommitdiff
path: root/examples/subcommands.py
Commit message (Collapse)AuthorAgeFilesLines
* Add black for automatic code formatTodd Leonhardt2021-01-311-0/+2
|
* Added info on semantic versioning and branching strategy to CONTRIBUTING.mdTodd Leonhardt2020-04-241-0/+1
| | | | | | | Also: - Added isort to Pipenv dev - Added setup.cfg to make it easy to run flake8, doc8, and isort directly from the command line without using invoke - Ran isort to sort includes
* Removed all instances where a parser's prog attribute was being set since ↵Kevin Van Brunt2019-10-301-2/+2
| | | | this is no longer needed
* Changed all uses of sub-command to subcommandKevin Van Brunt2019-07-191-21/+21
|
* Fixing unit testsKevin Van Brunt2019-07-041-4/+2
|
* 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
* Using sub-command instead of subcommand where possible to be consistent with ↵Kevin Van Brunt2018-10-051-21/+21
| | | | argparse
* Added the the ability to format help to the AutoCompleter to support ↵Eric Lin2018-09-231-0/+38
| | | | sub-command specific help lookup.
* Simplify subcommnads.py exampleTodd Leonhardt2018-05-311-21/+2
|
* Standardize cmd2 imports in tests and exampleskotfu2018-05-231-3/+2
|
* Fixes problem with not passing the parameter hint suppression down to ↵Eric Lin2018-05-221-0/+4
| | | | | | | | sub-commands Added hint suppression on a per-parameter basis Added helper function to force an parameter to fall back to bash completion instead of using Cmd2 completion. - Hinting is still enabled by default but can be suppressed in the helper function.
* Another attempt at getting it working on travis.Eric Lin2018-05-041-3/+0
|
* Added checks to detect if argcomplete is installed.Eric Lin2018-04-251-12/+17
|
* Removed the expensive imports from cmd2/__init__.pyEric Lin2018-04-251-29/+42
| | | | | | | 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 some more comments for clarification.Eric Lin2018-04-211-1/+1
|
* Switched the default behavior in cmd2 for argparse commands to use the ↵Eric Lin2018-04-211-10/+1
| | | | AutoCompleter by default.
* Changed cmd2 to use autocompleter by default for all argparse commands. Not ↵Eric Lin2018-04-201-4/+11
| | | | all tests are passing yet.
* Started removing dependency on sixTodd Leonhardt2018-04-151-1/+1
| | | | | | | Removed all dependency on six other than for six.moves.input Also: - Started removing code branches which were for Python 2 support
* Simplified how to add tab completion to a subcommandKevin Van Brunt2018-03-281-6/+11
|
* Removed unused importsKevin Van Brunt2018-03-251-2/+0
|
* Made subcommand specific completion work with Python 2 in the examplesKevin Van Brunt2018-03-241-6/+4
|
* Fixed check for whether a subcommand was enteredKevin Van Brunt2018-03-231-2/+3
|
* Added a default signal handler for SIGINT (Ctrl-C)Todd Leonhardt2018-03-191-3/+3
| | | | | | | | | | Added a default signal handler for SIGINT that does the following: - Terminates a pipe process if one exists - Raises a KeyboardInterrupt for other parts othe code to catch Also: - Changed the default value for quit_on_sigint to False - Modified the way the subcommand functions are called in subcommand.py (unrelated to rest of commit)
* Fix unit tests and exampleTodd Leonhardt2018-03-161-2/+5
| | | | | | 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-7/+27
|
* No longer need to manually specify subcommand names for tab completionKevin Van Brunt2018-03-141-4/+1
|
* Fixed typoKevin Van Brunt2018-03-011-1/+1
|
* 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-2/+2
|
* Tab-completion of subcommand names is now supportedTodd Leonhardt2018-01-201-1/+4
|
* Just improved a few comments in the subcommands.py exampleTodd Leonhardt2018-01-201-3/+3
|
* Added support for argparse sub-commands when using cmd2 decoratorsTodd Leonhardt2018-01-201-0/+58
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.