Skip to content

Commit ddfd3d9

Browse files
authored
Merge pull request #257 from python-cmd2/sub-commands
Sub-commands and automatic transcript generation
2 parents 7b564b4 + 504e3db commit ddfd3d9

19 files changed

+650
-78
lines changed

CHANGELOG.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,40 @@
11
## 0.8.0 (TBD, 2018)
22
* Bug Fixes
33
* Fixed unit tests on Python 3.7 due to changes in how re.escape() behaves in Python 3.7
4+
* Fixed a bug where unknown commands were getting saved in the history
45
* Enhancements
56
* Three new decorators for **do_*** commands to make argument parsing easier
67
* **with_argument_list** decorator to change argument type from str to List[str]
78
* **do_*** commands get a single argument which is a list of strings, as pre-parsed by shlex.split()
89
* **with_argument_parser** decorator for strict argparse-based argument parsing of command arguments
910
* **do_*** commands get a single argument which is the output of argparse.parse_args()
10-
* **with_argparser_and_unknown_args** decorator for argparse-based argument parsing, but allowing unknown args
11+
* **with_argparser_and_unknown_args** decorator for argparse-based argument parsing, but allows unknown args
1112
* **do_*** commands get two arguments, the output of argparse.parse_known_args()
12-
* See the **Argument Processing** section of the documentation for more information on these decorators
13-
* Alternatively, see the **argparse_example.py** and **arg_print.py** examples
13+
* See the [Argument Processing](http://cmd2.readthedocs.io/en/latest/argument_processing.html) section of the documentation for more information on these decorators
14+
* Alternatively, see the [argparse_example.py](https://github.com/python-cmd2/cmd2/blob/master/examples/argpasre_example.py)
15+
and [arg_print.py](https://github.com/python-cmd2/cmd2/blob/master/examples/arg_print.py) examples
16+
* Added support for Argpasre sub-commands when using the **with_argument_parser** or **with_argparser_and_unknown_args** decorators
17+
* See [subcommands.py](https://github.com/python-cmd2/cmd2/blob/master/examples/subcommands.py) for an example of how to use subcommands
18+
* Tab-completion of sub-command names is automatically supported
1419
* The **__relative_load** command is now hidden from the help menu by default
1520
* This command is not intended to be called from the command line, only from within scripts
1621
* The **set** command now has an additional **-a/--all** option to also display read-only settings
17-
* The **history** command can now run, edit, and save prior commands, in addition to the prior behavior of displaying prior commands.
22+
* The **history** command can now run, edit, and save prior commands, in addition to displaying prior commands.
23+
* The **history** command can now automatically generate a transcript file for regression testing
24+
* This feature works imperfectly at the moment, but it is still quite useful
1825
* Commands Removed
1926
* The **cmdenvironment** has been removed and its functionality incorporated into the **-a/--all** argument to **set**
2027
* The **show** command has been removed. Its functionality has always existing within **set** and continues to do so
21-
* The **save** command has been removed. The capability to save prior commands is now part of the **history** command.
28+
* The **save** command has been removed. The capability to save commands is now part of the **history** command.
2229
* The **run** command has been removed. The capability to run prior commands is now part of the **history** command.
2330
* Other changes
2431
* The **edit** command no longer allows you to edit prior commands. The capability to edit prior commands is now part of the **history** command. The **edit** command still allows you to edit arbitrary files.
2532
* the **autorun_on_edit** setting has been removed.
33+
* For Python 3.4 and earlier, ``cmd2`` now has an additional dependency on the ``contextlib2`` module
2634
* Deprecations
2735
* The old **options** decorator for optparse-based argument parsing is now *deprecated*
28-
* The old decorator is still present for now, but will eventually be removed in a future release
29-
* ``cmd2`` no longer includes **optparse.make_option** so if your app needs it you need to import it directly from optparse
30-
36+
* The old decorator is still present for now, but will be removed in a future release
37+
* ``cmd2`` no longer includes **optparse.make_option**, so if your app needs it import directly from optparse
3138

3239
## 0.7.9 (January 4, 2018)
3340

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ Main Features
2929
- Multi-line, case-insensitive, and abbreviated commands
3030
- Special-character command shortcuts (beyond cmd's `@` and `!`)
3131
- Settable environment parameters
32-
- Parsing commands with arguments using `argparse`
32+
- Parsing commands with arguments using `argparse`, including support for sub-commands
3333
- Unicode character support (*Python 3 only*)
34-
- Good tab-completion of commands, file system paths, and shell commands
34+
- Good tab-completion of commands, sub-commands, file system paths, and shell commands
3535
- Python 2.7 and 3.4+ support
36-
- Linux, macOS and Windows support
36+
- Windows, macOS, and Linux support
3737
- Trivial to provide built-in help for all commands
3838
- Built-in regression testing framework for your applications (transcript-based testing)
3939

@@ -48,8 +48,9 @@ pip install -U cmd2
4848

4949
cmd2 works with Python 2.7 and Python 3.4+ on Windows, macOS, and Linux. It is pure Python code with
5050
the only 3rd-party dependencies being on [six](https://pypi.python.org/pypi/six),
51-
[pyparsing](http://pyparsing.wikispaces.com), and [pyperclip](https://github.com/asweigart/pyperclip)
52-
(on Windows, [pyreadline](https://pypi.python.org/pypi/pyreadline) is an additional dependency).
51+
[pyparsing](http://pyparsing.wikispaces.com), and [pyperclip](https://github.com/asweigart/pyperclip).
52+
Windows has an additional dependency on [pyreadline](https://pypi.python.org/pypi/pyreadline) and Python
53+
3.4 and earlier have an additional dependency on [contextlib2](https://pypi.python.org/pypi/contextlib2).
5354

5455
For information on other installation options, see
5556
[Installation Instructions](https://cmd2.readthedocs.io/en/latest/install.html) in the cmd2

0 commit comments

Comments
 (0)