Cmd2

Latest version: v2.4.3

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

Scan your dependencies

Page 3 of 15

2.0.0

* Bug Fixes
* Fixed issue where history indexes could get repeated
* Fixed issue where TableCreator was tossing blank last line
* Corrected help text for alias command
* Breaking Changes
* `cmd2` 2.0 supports Python 3.6+ (removed support for Python 3.5)
* Argparse Completion / Settables
* Replaced `choices_function` / `choices_method` with `choices_provider`.
* Replaced `completer_function` / `completer_method` with `completer`.
* ArgparseCompleter now always passes `cmd2.Cmd` or `CommandSet` instance as the first positional
argument to choices_provider and completer functions.
* Moved `basic_complete` from utils into `cmd2.Cmd` class.
* Moved `CompletionError` to exceptions.py
* ``Namespace.__statement__`` has been removed. Use `Namespace.cmd2_statement.get()` instead.
* Removed `--silent` flag from `alias/macro create` since startup scripts can be run silently.
* Removed `--with_silent` flag from `alias/macro list` since startup scripts can be run silently.
* Removed `with_argparser_and_unknown_args` since it was deprecated in 1.3.0.
* Renamed `silent_startup_script` to `silence_startup_script` for clarity.
* Replaced `cmd2.Cmd.completion_header` with `cmd2.Cmd.formatted_completions`. See Enhancements
for description of this new class member.
* Settables now have new initialization parameters. It is now a required parameter to supply the reference to the
object that holds the settable attribute. `cmd2.Cmd.settables` is no longer a public dict attribute - it is now a
property that aggregates all Settables across all registered CommandSets.
* Failed transcript testing now sets self.exit_code to 1 instead of -1.
* Renamed `use_ipython` keyword parameter of `cmd2.Cmd.__init__()` to `include_ipy`.
* `py` command is only enabled if `include_py` parameter is `True`. See Enhancements for a description
of this parameter.
* Removed ability to run Python commands from the command line with `py`. Now `py` takes no arguments
and just opens an interactive Python shell.
* Changed default behavior of `runcmds_plus_hooks()` to not stop when Ctrl-C is pressed and instead
run the next command in its list.
* Removed `cmd2.Cmd.quit_on_sigint` flag, which when `True`, quit the application when Ctrl-C was pressed at the prompt.
* The history bug fix resulted in structure changes to the classes in `cmd2.history`. Therefore, persistent history
files created with versions older than 2.0.0 are not compatible.
* Enhancements
* Added support for custom tab completion and up-arrow input history to `cmd2.Cmd2.read_input`.
See [read_input.py](https://github.com/python-cmd2/cmd2/blob/master/examples/read_input.py)
for an example.
* Added `cmd2.exceptions.PassThroughException` to raise unhandled command exceptions instead of printing them.
* Added support for ANSI styles and newlines in tab completion results using `cmd2.Cmd.formatted_completions`.
`cmd2` provides this capability automatically if you return argparse completion matches as `CompletionItems`.
* Settables enhancements:
* Settables may be optionally scoped to a CommandSet. Settables added to CommandSets will appear when a
CommandSet is registered and disappear when a CommandSet is unregistered. Optionally, scoped Settables
may have a prepended prefix.
* Settables now allow changes to be applied to any arbitrary object attribute. It no longer needs to match an
attribute added to the cmd2 instance itself.
* Raising ``SystemExit`` or calling ``sys.exit()`` in a command or hook function will set ``self.exit_code``
to the exit code used in those calls. It will also result in the command loop stopping.
* ipy command now includes all of `self.py_locals` in the IPython environment
* Added `include_py` keyword parameter to `cmd2.Cmd.__init__()`. If `False`, then the `py` command will
not be available. Defaults to `False`. `run_pyscript` is not affected by this parameter.
* Made the amount of space between columns in a SimpleTable configurable
* On POSIX systems, shell commands and processes being piped to are now run in the user's preferred shell
instead of /bin/sh. The preferred shell is obtained by reading the SHELL environment variable. If that
doesn't exist or is empty, then /bin/sh is used.
* Changed `cmd2.Cmd._run_editor()` to the public method `cmd2.Cmd.run_editor()`

1.5.0

* Bug Fixes
* Fixed bug where setting `always_show_hint=True` did not show a hint when completing `Settables`
* Fixed bug in editor detection logic on Linux systems that do not have `which`
* Fixed bug in table creator where column headers with tabs would result in an incorrect width calculation
* Fixed `FileNotFoundError` which occurred when running `history --clear` and no history file existed.
* Enhancements
* Added `silent_startup_script` option to `cmd2.Cmd.__init__()`. If `True`, then the startup script's
output will be suppressed. Anything written to stderr will still display.
* cmd2 now uses pyreadline3 when running Python 3.8 or greater on Windows
* Notes
* This is the last release planned to support Python 3.5

1.4.0

* Bug Fixes
* Fixed tab completion crash on Windows
* Enhancements
* Changed how multiline doc string help is formatted to match style of other help messages

1.3.11

* Bug Fixes
* Fixed issue where quoted redirectors and terminators in aliases and macros were not being
restored when read from a startup script.
* Fixed issue where instantiating more than one cmd2-based class which uses the `as_subcommand_to`
decorator resulted in duplicated help text in the base command the subcommands belong to.

1.3.10

* Enhancements
* Added user-settable option called `always_show_hint`. If True, then tab completion hints will always
display even when tab completion suggestions print. Arguments whose help or hint text is suppressed will
not display hints even when this setting is True.
* argparse tab completion now groups flag names which run the same action. Optional flags are wrapped
in brackets like it is done in argparse usage text.
* default category decorators are now heritable by default and will propagate the category down the
class hierarchy until overridden. There's a new optional flag to set heritable to false.
* Added `--silent` flag to `alias/macro create`. If used, then no confirmation message will be printed
when aliases and macros are created or overwritten.
* Added `--with_silent` flag to `alias/macro list`. Use this option when saving to a startup script
that should silently create aliases and macros.
* Bug Fixes
* Fixed issue where flag names weren't always sorted correctly in argparse tab completion

1.3.9

* Breaking Changes
* `CommandSet.on_unregister()` is now called as first step in unregistering a `CommandSet` and not
the last. `CommandSet.on_unregistered()` is now the last step.
* Enhancements
* Added `CommandSet.on_registered()`. This is called by `cmd2.Cmd` after a `CommandSet` is registered
and all its commands have been added to the CLI.
* Added `CommandSet.on_unregistered()`. This is called by `cmd2.Cmd` after a `CommandSet` is unregistered
and all its commands have been removed from the CLI.

Page 3 of 15

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.