summaryrefslogtreecommitdiff
path: root/examples
Commit message (Collapse)AuthorAgeFilesLines
* Updated comments and examplesKevin Van Brunt2018-04-151-2/+2
|
* Added a with_category decorator that can be used to tag a command category.Eric Lin2018-04-111-6/+6
| | | | | | | | | Changed the detection of with_argparse decorated commands to be less hacky/brittle. Now it tags the function with help_summary. Fixed issue with handling commands that provide a custom help_ function. We can now redirect the output to a string to be formatted with the other commands. Added some documentation explaining the new help categories. Updated unit tests.
* Fixed issue where categorization is skipped when there's a help_<command> ↵Eric Lin2018-04-111-1/+8
| | | | | | | | function provided. In verbose help, added check for argparse usage block (starting with 'usage: '), to skip that block and move to the next comment block Added unit tests for new categorization code Updated example to demonstrate skipping of argparse usage statement
* Added verbose help output with help -v or help --verboseEric Lin2018-04-101-1/+8
| | | | | Reads the __doc__ for a command function and provides the first block of text for each command. Updated help_categories.py to demonstrate a multi-line comment block for a command.
* Added a convenience function for tagging command categories.Eric Lin2018-04-091-19/+19
|
* Added ability to group commands by category when printing the help menu.Eric Lin2018-04-091-0/+131
| | | | Added example of multiple commands grouped by categories
* Simplified how to add tab completion to a subcommandKevin Van Brunt2018-03-281-6/+11
|
* Addressed code review commentsKevin Van Brunt2018-03-272-5/+4
|
* Removed unused importsKevin Van Brunt2018-03-251-2/+0
|
* Made subcommand specific completion work with Python 2 in the examplesKevin Van Brunt2018-03-242-29/+31
|
* Merge branch 'master' into new_quoted_completionKevin Van Brunt2018-03-231-2/+3
|\
| * Fixed check for whether a subcommand was enteredKevin Van Brunt2018-03-231-2/+3
| |
* | Renamed exclude_from_help to hidden_commandsKevin Van Brunt2018-03-221-4/+4
|/ | | | | Renamed excludeFromHistory to exclude_from_history No longer tab completing hidden commands
* Added an extra check to ppaged() to make sure cmd2 app is running in a real ↵Todd Leonhardt2018-03-201-0/+4
| | | | terminal before attempting to use a pager
* 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)
* Merge branch 'master' into startup_scriptTodd Leonhardt2018-03-161-4/+0
|\
| * Updated one example so it can be used properly with default_to_shellTodd Leonhardt2018-03-161-4/+0
| |
* | Added ability to specify a startup_script in cmd2.Cmd.__init__()Todd Leonhardt2018-03-162-0/+26
|/
* 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
|
* Added table_display.pyTodd Leonhardt2018-03-141-0/+64
| | | | | | | | Added example showing how to display tabular data in a cmd2 application. Also: - Updated CHANGELOG with data on all PRs since last release - Bumped version to 0.8.2 in preparation for next release
* Use self.poutput() instead of print() in arg_print.py exampleTodd Leonhardt2018-03-071-4/+4
|
* Added ppaged() method for printing output via a pagerTodd Leonhardt2018-03-071-0/+29
| | | | | | Also: - Added paged_output.py example - Modified cmd2 so it keeps track of when output is being redirected so it doesn't attempt to usage a pager in this case
* Removed support for case-insensitive command parsingTodd Leonhardt2018-03-021-25/+0
|
* Removed abbrev attributeKevin Van Brunt2018-03-023-3/+0
|
* Fixed some parsing bugs and added more unit testsKevin Van Brunt2018-03-021-1/+7
|
* Added tab completion exampleKevin Van Brunt2018-03-021-0/+69
|
* Fixed typoKevin Van Brunt2018-03-011-1/+1
|
* Fixed python_scripting.py exampleTodd Leonhardt2018-03-011-11/+11
| | | | - Since path_complete got moved outside of cmd2.Cmd and is now a function instead of a method, need to do partial argument binding with functools.partial() instead of functools.partialmethod()
* Fixed removed_unused.py example and help for edit commandTodd Leonhardt2018-02-241-2/+2
| | | | | | | | | The remove_unused.py example had become outdated since the cmdenvironment command no longer exists. The help text for the edit command was outdated since the functionality for editing previous commands got moved from the edit command to the history command. This closes #276. This closes #282.
* Make sure pexpect uses same version of Python to spawn persistent history ↵Todd Leonhardt2018-02-091-4/+14
| | | | example
* First past at unit test for persistent history featureTodd Leonhardt2018-02-091-0/+1
| | | | | | Added pexpect to modules required for running unit tests. This opens the door for carefully crafted complex unit tests to verify intricate behavior. Tests like this are somewhat painful to write and slow to execute. However, they can enable testing complicated interactive behavior that we otherwise probably would not be able to test.
* Added optional persistent readline history featureTodd Leonhardt2018-02-082-5/+23
| | | | | | | | | | | | - Including an example and info in the Sphinx docs Also: - Created CHANGELOG entry for 0.8.1 release - Added info to README about new sub-menu feature - Bumped version to 0.8.1 TODO: - Added a unit test for the persistent readline history feature
* Added ability to use ipy for embedded IPython to submenus.py exampleTodd Leonhardt2018-02-071-1/+23
| | | | This is simply to allow introspection on self for debug and development
* Fixed typo in ThirdLevel.do_say() printCalvin Lobo2018-02-041-1/+2
| | | | Added shebang line
* Merge branch 'master' into feature/submenuTodd Leonhardt2018-02-039-90/+236
|\
| * Renamed @with_argument_parser decorator to @with_argparserTodd Leonhardt2018-01-215-16/+16
| | | | | | | | | | Also: - Reanamed foo and bar subcommand methods to base_foo and base_bar
| * History enhancementsTodd Leonhardt2018-01-204-8/+18
| | | | | | | | | | | | | | | | | | | | 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 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.
| * Simplified a few argparse examples and fixed some incorrect documentationTodd Leonhardt2018-01-172-4/+4
| | | | | | | | | | | | 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/+1
| | | | | | | | | | | | 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-173-3/+0
| | | | | | | | Removed usage of and reference to attributes and commands which have now been removed.
| * Renamed new decorator to @with_argparser_and_unknown_args to make it more ↵Todd Leonhardt2018-01-152-4/+4
| | | | | | | | descriptive
| * Changed @with_argument_parser to only pass single argument to commandsTodd Leonhardt2018-01-155-32/+56
| | | | | | | | 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.
| * Modified examples still using @options to import make_option from optparseTodd Leonhardt2018-01-153-12/+14
| |
| * Made a couple cleanup changesTodd Leonhardt2018-01-152-24/+29
| | | | | | | | | | | | | | | | | | 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