summaryrefslogtreecommitdiff
path: root/examples/example.py
Commit message (Collapse)AuthorAgeFilesLines
* Adds pre-commit config to run various lintersci_improvementsxNinjaKittyx2020-12-151-4/+5
| | | | | | | This ads black, isort, pyupgrade, and flake8 to pre-commit-config.yaml There are also some small changes to travis.yml and tasks.py to reduce some repeated configurations that should be consolidated into setup.cfg. Most other changes are automated by the linter scripts.
* Added cmd2.utils.Settable to the cmd2 namespace and updated examples and docsTodd Leonhardt2020-02-041-1/+1
|
* Fix lint error for unused variablekotfu2019-07-141-1/+1
|
* Added a walkthrough of constructing a simple application to the overviewkotfu2019-07-051-4/+3
| | | | For #709
* Fixed a bunch of examples which were broken due to moving DEFAULT_SHORTCUTS ↵Todd Leonhardt2019-06-161-1/+1
| | | | from cmd2.py to constants.py
* Refactor exit_code implementationTodd Leonhardt2019-05-201-3/+3
| | | | | | | | | | | | 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
* Fixed how shortcuts are set in examplesTodd Leonhardt2019-03-141-6/+4
|
* First stage of attribute refactoringTodd Leonhardt2019-03-131-2/+1
| | | | | | | | | | The following are now arguments to cmd2.Cmd.__init__() instead of class attributes: * allow_redirection * multiline_commands * terminators * shortcuts Added a couple read-only properties for convenience of cmd2.Cmd accessing immutable members from self.statement_parser
* Changed examples to reflect that settable doesn't need to be updated before ↵Kevin Van Brunt2019-02-201-2/+4
| | | | calling init()
* Standardize cmd2 imports in tests and exampleskotfu2018-05-231-4/+4
|
* Merge branch 'test_merge' into test_ply_mergeEric Lin2018-05-021-1/+1
|\
| * Removed the expensive imports from cmd2/__init__.pyEric Lin2018-04-251-1/+1
| | | | | | | | | | | | | | 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
* | multilineCommands -> multiline_commandskotfu2018-04-291-1/+1
|/
* 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
* Removed abbrev attributeKevin Van Brunt2018-03-021-1/+0
|
* 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
* Changed @with_argument_parser to only pass single argument to commandsTodd Leonhardt2018-01-151-2/+2
| | | | 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-13/+16
| | | | | | | | | 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
* switch from optparse to argparseJared Crapo2018-01-101-25/+26
|
* Made a couple fixes to existing examplesTodd Leonhardt2017-11-111-2/+2
| | | | | | | 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
* Make the same as test_transcription.pyJared Crapo2017-08-211-4/+5
|
* Write documentation for revised transcription featureJared Crapo2017-08-211-10/+33
|
* Fixed a few bugs and examplesTodd Leonhardt2017-07-031-0/+1
| | | | | | | | | | | | | | 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
* 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.
* Changed default value for USE_ARG_LIST global to TrueTodd Leonhardt2017-06-141-1/+4
| | | | | | | | | | | 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.
* Mostly fix a bunch of spelling mistakes.Todd Leonhardt2017-03-131-1/+1
| | | | A few other miscellaneous minor tweaks for whitespace and such.
* Changes to make our project as welcoming as possible for new contributors.Todd Leonhardt2017-02-261-0/+53
Changes include: 1) Added CONTRIBUTING.md with detailed instructions for how to contribute, which should be especially useful to those new to open source in general or GitHub in particular 2) Added CODE_OF_CONDUCT.md which sets ground rules for participants’ behavior and helps to facilitate a friendly, welcoming environment 3) Renamed the "example" directory to "examples" in the hope that one day soon there may be more than a single example ;-)