summaryrefslogtreecommitdiff
path: root/examples
Commit message (Collapse)AuthorAgeFilesLines
* 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
* remove use_argument_list attributekotfu2018-01-141-40/+0
|
* add use_argument_list settingkotfu2018-01-121-0/+40
| | | | 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-5/+15
|
* @with_argument_parser now passes an arglist instead of a stringkotfu2018-01-121-2/+2
|
* simplify outputJared Crapo2018-01-101-6/+3
|
* switch from optparse to argparseJared Crapo2018-01-101-25/+26
|
* Clean up variable nameskotfu2018-01-071-2/+2
|
* Set prog in argparser based on the name of the functionkotfu2018-01-071-4/+1
|
* Properly set docstring so it contains help messagekotfu2018-01-071-36/+36
|
* Add tests for POSIX=true and arguments containing spaceskotfu2018-01-071-2/+18
|
* Default posix and quote removal working.kotfu2018-01-071-15/+17
|
* Merge branch 'master' of https://github.com/python-cmd2/cmd2 into argparseJared Crapo2017-12-114-82/+35
|\
| * Made a couple fixes to existing examplesTodd Leonhardt2017-11-113-81/+27
| | | | | | | | | | | | | | Changes include: - argparse_example.py modified to do pass all unknown args onto cmd2 and allow arguments at invocation - example.py comments modified to indicate it is intended to be used with transcript_regext.txt - exampleSession.txt fixed so it works properly with argparse_example.py
| * Updated docs to make it more clear that you need to update shortcuts ↵Todd Leonhardt2017-11-091-1/+8
| | | | | | | | attribute before calling super class __init__
* | Plan and first working code for argparse decoratorJared Crapo2017-12-111-1/+25
|/
* Improved documentation for how a user can modify comment grammar/styleTodd Leonhardt2017-09-221-0/+39
| | | | | | | Also: - Added arg_print.py example to demonstrate this - Bumped version to 0.7.8a - Updated CHANGELOG
* Revise environment setting documentationkotfu2017-08-281-0/+38
|
* Make the same as test_transcription.pyJared Crapo2017-08-211-4/+5
|
* regex implementation complete. Still a few bugs.Jared Crapo2017-08-211-3/+4
|
* Write documentation for revised transcription featureJared Crapo2017-08-211-10/+33
|
* feedback_to_output now defaults to FalseTodd Leonhardt2017-08-201-2/+2
| | | | This is so that non-essential info which isn't directly associated with command output, such as time elapsed while executing a command, won't redirect when command output is redirected using >, >>, or |.
* Ensure editor and the file to edit can have spaces in themJared Crapo2017-08-191-2/+3
|
* Added remove_unused.py example to demonstrate how to remove unused commandsTodd Leonhardt2017-07-311-0/+30
|
* Fixed a couple case sensitivity bugs and added an exampleTodd Leonhardt2017-07-121-0/+25
| | | | | | | | Bugs fixed: - Case-sensitive parsing was completely broken, this has been fixed - <Ctrl>+D to quit wasn't working when case-sensitive parsing was enabled, this is fixed Added a "case_sensitive.py" example in the examples directory for quickly testing case-sensitive command parsing behavior.
* Fixed a few bugs and examplesTodd Leonhardt2017-07-034-18/+22
| | | | | | | | | | | | | | Bug fixes: - case_insensitive is no longer a runtime-settable parameter, but it was still listed as such - Fixed a recursive loop bug when abbreviated commands are enabled and it could get stuck in the editor forever - Added additional command abbreviations to the "exclude from history" list - Fixed argparse_example.py and pirate.py examples Other changes: - Organized all attributes used to configure the ParserManager into a single location - Set the default value of "abbrev" to False (which controls whether or not abbreviated commands are allowed) - With good tab-completion of command names, using abbreviated commands isn't a particularly useful feature - And it can create problems
* Removed pause commandTodd Leonhardt2017-07-031-3/+2
| | | | | | It was pretty useless, it just printed a message and sat there and waited for the user to hit enter. It didn't feel like it belonged in a top-level framework. If a particular application wants this functionality, it is a 2 line change to add it back.
* Add screenshot to front pageTodd Leonhardt2017-07-031-1/+1
| | | | | | | Also: - Updated pythong_scripting.py example to show how to colorize text - Updated contributing.md to show how to run code coverage in parallel using python-xdist and -nauto - Updated contributing.md to talk more about looking at unit test results within the PR
* Refactored to replace custom StubbornDict with collections.OrderedDictTodd Leonhardt2017-06-291-4/+7
| | | | The self.settable object is now an OrderedDict instead of a custom StubbornDict.
* Completely removed use of self.default_file_nameTodd Leonhardt2017-06-281-2/+1
| | | | | | | | Load and relative load now require a file path Edit will use a temporary file by default and delete it when done Save will use a temporary file by default and inform the user what it is Also changed the default value for autorun_on_edit to False so that it can safely be used as an actual file editor.
* Simplified implementation of do__relative_loadTodd Leonhardt2017-06-281-0/+3
| | | | Also removed default argument for _relative_load and load
* Moved example scripts from examples to examples/scripts directlyTodd Leonhardt2017-06-215-2/+2
| | | | | | Cleaned up the examples directory by adding a scripts subdirectory. This makes it a bit clearer which Python files are example cmd2 applications and which are example Python scripts for use with the pyscript command.
* Changed default value for USE_ARG_LIST global to TrueTodd Leonhardt2017-06-142-4/+7
| | | | | | | | | | | Now by default all @options commands get passed a list of argument strings instead of a single argument string. This is a much easier and more robust behavior to deal with. Additionally, command-line arguments are intelligently separated based on location of quotes to group things into a single argument. WARNING: This change breaks backward compatibility for older applicaitons based on cmd2. To change the behavior to the way it used to be, add the following code to the __init__() method of our class derived from cmd2.Cmd: cmd2.set_use_arg_list(False) This change really does make it easier for developers new to using cmd2 however. It is to the point where I create all custom commands with @options, even if I use an empty list for the options because the argument parsing is just much better this way.
* Updated documentation and examplesTodd Leonhardt2017-06-143-16/+27
| | | | | | | | | Added information related to the new pyscript command. The old way of running Python scripts via "py run()" should be considered deprecated. The new "pyscript" command is superior in two significant ways: 1) It supports tab-completion of file system paths 2) It allows the user to pass command-line arguments to scripts
* Added new pyscript commandTodd Leonhardt2017-06-132-2/+9
| | | | | | | | This command is explicitly for running Python script files within an embedded Python interpreter. The advantages over the py command with "run" are: - Tab-completion of file system paths is supported - Command-line arguments can be passed to the Python script
* Updated example transcript test and docsTodd Leonhardt2017-06-031-2/+2
| | | | Updated these to reflect that the list command has been removed
* Updated an example, features, and changes based on new support for path and ↵Todd Leonhardt2017-05-171-12/+3
| | | | command completion
* Apparently regex syntax is stricter for Python 3 on Windows.Todd Leonhardt2017-03-162-1/+3
| | | | | | Than it is for Python 2 on Windows or Python 3 on Linux or Mac. Go figure. You would think it would be the same for Python 3 across platforms.