Cmd2

Latest version: v2.5.11

Safety actively analyzes 723158 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 10 of 17

0.9.19

- Bug Fixes
- Fixed `ValueError` exception which could occur when an old format persistent history file is loaded with new `cmd2`
- Enhancements
- Improved displaying multiline CompletionErrors by indenting all lines

0.9.18

- Bug Fixes
- Fixed bug introduced in 0.9.17 where help functions for hidden and disabled commands were not being filtered
out as help topics
- Enhancements
- `AutoCompleter` now handles argparse's mutually exclusive groups. It will not tab complete flag names or positionals
for already completed groups. It also will print an error if you try tab completing a flag's value if the flag
belongs to a completed group.
- `AutoCompleter` now uses the passed-in parser's help formatter to generate hint text. This gives help and
hint text for an argument consistent formatting.

0.9.17

- Bug Fixes
- Fixed a bug when using WSL when all Windows paths have been removed from $PATH
- Fixed a bug when running a cmd2 application on Linux without Gtk libraries installed
- Enhancements
- No longer treating empty text scripts as an error condition
- Allow dynamically extending a `cmd2.Cmd` object instance with a `do_xxx` method at runtime
- Choices/Completer functions can now be passed a dictionary that maps command-line tokens to their
argparse argument. This is helpful when one argument determines what is tab completed for another argument.
If these functions have an argument called `arg_tokens`, then AutoCompleter will automatically pass this
dictionary to them.
- Added CompletionError class that can be raised during argparse-based tab completion and printed to the user
- Added the following convenience methods
- `Cmd.in_script()` - return whether a text script is running
- `Cmd.in_pyscript()` - return whether a pyscript is running

0.9.16

- Bug Fixes
- Fixed inconsistent parsing/tab completion behavior based on the value of `allow_redirection`. This flag is
only meant to be a security setting that prevents redirection of stdout and should not alter parsing logic.
- Enhancements
- Raise `TypeError` if trying to set choices/completions on argparse action that accepts no arguments
- Create directory for the persistent history file if it does not already exist
- Added `set_choices_function()`, `set_choices_method()`, `set_completer_function()`, and `set_completer_method()`
to support cases where this functionality needs to be added to an argparse action outside of the normal
`parser.add_argument()` call.
- Breaking Changes
- Aliases and macros can no longer have the same name as a command

0.9.15

- Bug Fixes
- Fixed exception caused by tab completing after an invalid subcommand was entered
- Fixed bug where `history -v` was sometimes showing raw and expanded commands when they weren't different
- Fixed bug where multiline commands were having leading and ending spaces stripped. This would mess up quoted
strings that crossed multiple lines.
- Fixed a bug when appending to the clipboard where contents were in reverse order
- Fixed issue where run_pyscript failed if the script's filename had 2 or more consecutive spaces
- Fixed issue where completer function of disabled command would still run
- Enhancements
- Greatly simplified using argparse-based tab completion. The new interface is a complete overhaul that breaks
the previous way of specifying completion and choices functions. See header of [argparse_custom.py](https://github.com/python-cmd2/cmd2/blob/master/cmd2/argparse_custom.py)
for more information.
- Enabled tab completion on multiline commands
- **Renamed Commands Notice**
- The following commands were renamed in the last release and have been removed in this release
- `load` - replaced by `run_script`
- `_relative_load` - replaced by `_relative_run_script`
- `pyscript` - replaced by `run_pyscript`
- We apologize for any inconvenience, but the new names are more self-descriptive
- Lots of end users were confused particularly about what exactly `load` should be loading
- Breaking Changes
- Restored `cmd2.Cmd.statement_parser` to be a public attribute (no underscore)
- Since it can be useful for creating [post-parsing hooks](https://cmd2.readthedocs.io/en/latest/features/hooks.html#postparsing-hooks)
- Completely overhauled the interface for adding tab completion to argparse arguments. See enhancements for more details.
- `ACArgumentParser` is now called `Cmd2ArgumentParser`
- Moved `basic_complete` to utils.py
- Made optional arguments on the following completer methods keyword-only:
`delimiter_complete`, `flag_based_complete`, `index_based_complete`, `path_complete`, `shell_cmd_complete`
- Renamed history option from `--output-file` to `--output_file`
- Renamed `matches_sort_key` to `default_sort_key`. This value determines the default sort ordering of string
results like alias, command, category, macro, settable, and shortcut names. Unsorted tab completion results
also are sorted with this key. Its default value (ALPHABETICAL_SORT_KEY) performs a case-insensitive alphabetical
sort, but it can be changed to a natural sort by setting the value to NATURAL_SORT_KEY.
- `StatementParser` now expects shortcuts to be passed in as dictionary. This eliminates the step of converting the
shortcuts dictionary into a tuple before creating `StatementParser`.
- Renamed `Cmd.pyscript_name` to `Cmd.py_bridge_name`
- Renamed `Cmd.pystate` to `Cmd.py_locals`
- Renamed `PyscriptBridge` to `PyBridge`

0.9.14

- Enhancements
- Added support for and testing with Python 3.8, starting with 3.8 beta
- Improved information displayed during transcript testing
- Added `ansi` module with functions and constants to support ANSI escape sequences which are used for things
like applying style to text
- Added support for applying styles (color, bold, underline) to text via `style()` function in `ansi` module
- Added default styles to ansi.py for printing `success`, `warning`. and `error` text. These are the styles used
by cmd2 and can be overridden to match the color scheme of your application.
- Added `ansi_aware_write()` function to `ansi` module. This function takes into account the value of `allow_ansi`
to determine if ANSI escape sequences should be stripped when not writing to a tty. See documentation for more
information on the `allow_ansi` setting.
- Breaking Changes
- Python 3.4 reached its [end of life](https://www.python.org/dev/peps/pep-0429/) on March 18, 2019 and is no longer supported by `cmd2`
- If you need to use Python 3.4, you should pin your requirements to use `cmd2` 0.9.13
- Made lots of changes to minimize the public API of the `cmd2.Cmd` class
- Attributes and methods we do not intend to be public now all begin with an underscore
- We make no API stability guarantees about these internal functions
- Split `perror` into 2 functions:
- `perror` - print a message to sys.stderr
- `pexcept` - print Exception message to sys.stderr. If debug is true, print exception traceback if one exists
- Signature of `poutput` and `perror` significantly changed
- Removed color parameters `color`, `err_color`, and `war_color` from `poutput` and `perror`
- See the docstrings of these methods or the [cmd2 docs](https://cmd2.readthedocs.io/en/latest/features/generating_output.html) for more info on applying styles to output messages
- `end` argument is now keyword-only and cannot be specified positionally
- `traceback_war` no longer exists as an argument since it isn't needed now that `perror` and `pexcept` exist
- Moved `cmd2.Cmd.colors` to ansi.py and renamed it to `allow_ansi`. This is now an application-wide setting.
- Renamed the following constants and moved them to ansi.py
- `COLORS_ALWAYS` --> `ANSI_ALWAYS`
- `COLORS_NEVER` --> `ANSI_NEVER`
- `COLORS_TERMINAL` --> `ANSI_TERMINAL`
- **Renamed Commands Notice**
- The following commands have been renamed. The old names will be supported until the next release.
- `load` --> `run_script`
- `_relative_load` --> `_relative_run_script`
- `pyscript` --> `run_pyscript`

Page 10 of 17

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.