Cmd2

Latest version: v2.4.3

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

Scan your dependencies

Page 9 of 15

0.9.12

* Bug Fixes
* Fixed a bug in how redirection and piping worked inside ``py`` or ``pyscript`` commands
* Fixed bug in `async_alert` where it didn't account for prompts that contained newline characters
* Fixed path completion case when CWD is just a slash. Relative path matches were incorrectly prepended with a slash.
* Enhancements
* Added ability to include command name placeholders in the message printed when trying to run a disabled command.
* See docstring for ``disable_command()`` or ``disable_category()`` for more details.
* Added instance attributes to customize error messages without having to override methods. Theses messages can
also be colored.
* `help_error` - the error that prints when no help information can be found
* `default_error` - the error that prints when a non-existent command is run
* The `with_argparser` decorators now add the Statement object created when parsing the command line to the
`argparse.Namespace` object they pass to the `do_*` methods. It is stored in an attribute called `__statement__`.
This can be useful if a command function needs to know the command line for things like logging.
* Added a `-t` option to the `load` command for automatically generating a transcript based on a script file
* When in a **pyscript**, the stdout and stderr streams of shell commands and processes being piped to are now
captured and included in the ``CommandResult`` structure.
* Potentially breaking changes
* The following commands now write to stderr instead of stdout when printing an error. This will make catching
errors easier in pyscript.
* ``do_help()`` - when no help information can be found
* ``default()`` - in all cases since this is called when an invalid command name is run
* ``_report_disabled_command_usage()`` - in all cases since this is called when a disabled command is run
* Removed *** from beginning of error messages printed by `do_help()` and `default()`
* Significantly refactored ``cmd.Cmd`` class so that all class attributes got converted to instance attributes, also:
* Added ``allow_redirection``, ``terminators``, ``multiline_commands``, and ``shortcuts`` as optional arguments
to ``cmd2.Cmd.__init__()``
* A few instance attributes were moved inside ``StatementParser`` and properties were created for accessing them
* ``self.pipe_proc`` is now called ``self.cur_pipe_proc_reader`` and is a ``ProcReader`` class.
* Shell commands and commands being piped to while in a *pyscript* will function as if their output is going
to a pipe and not a tty. This was necessary to be able to capture their output.
* Removed `reserved_words` class attribute due to lack of use
* Removed `keywords` instance attribute due to lack of use

0.9.11

* Bug Fixes
* Fixed bug in how **history** command deals with multiline commands when output to a script
* Fixed a bug when the ``with_argument_list`` decorator is called with the optional ``preserve_quotes`` argument
* Fix bug in ``perror()`` where it would try to print an exception Traceback even if none existed
* Enhancements
* Improvements to the **history** command
* Simplified the display format and made it more similar to **bash**
* Added **-x**, **--expanded** flag
* output expanded commands instead of entered command (expands aliases, macros, and shortcuts)
* Added **-v**, **--verbose** flag
* display history and include expanded commands if they differ from the typed command
* Added support for negative indices
* Added ``matches_sort_key`` to override the default way tab completion matches are sorted
* Added ``StdSim.pause_storage`` member which when True will cause ``StdSim`` to not save the output sent to it.
See documentation for ``CommandResult`` in ``pyscript_bridge.py`` for reasons pausing the storage can be useful.
* Added ability to disable/enable individual commands and entire categories of commands. When a command
is disabled, it will not show up in the help menu or tab complete. If a user tries to run the command
or call help on it, a command-specific message supplied by the developer will be printed. The following
commands were added to support this feature.
* ``enable_command()``
* ``enable_category()``
* ``disable_command()``
* ``disable_category()``
* Potentially breaking changes
* Made ``cmd2_app`` a positional and required argument of ``AutoCompleter`` since certain functionality now
requires that it can't be ``None``.
* ``AutoCompleter`` no longer assumes ``CompletionItem`` results are sorted. Therefore you should follow the
``cmd2`` convention of setting ``self.matches_sorted`` to True before returning the results if you have already
sorted the ``CompletionItem`` list. Otherwise it will be sorted using ``self.matches_sort_key``.
* Removed support for bash completion since this feature had slow performance. Also it relied on
``AutoCompleter`` which has since developed a dependency on ``cmd2`` methods.
* Removed ability to call commands in ``pyscript`` as if they were functions (e.g. ``app.help()``) in favor
of only supporting one ``pyscript`` interface. This simplifies future maintenance.
* No longer supporting C-style comments. Hash () is the only valid comment marker.
* No longer supporting comments embedded in a command. Only command line input where the first
non-whitespace character is a will be treated as a comment. This means any character appearing
later in the command will be treated as a literal. The same applies to a in the middle of a multiline
command, even if it is the first character on a line.
* \ this is a comment
* this is not a comment

0.9.10

* Bug Fixes
* Fixed unit test that hangs on Windows

0.9.9

* Bug Fixes
* Fixed bug where the ``set`` command was not tab completing from the current ``settable`` dictionary.
* Enhancements
* Changed edit command to use do_shell() instead of calling os.system()

0.9.8

* Bug Fixes
* Fixed issue with echoing strings in StdSim. Because they were being sent to a binary buffer, line buffering
was being ignored.
* Enhancements
* Made quit() and exit() functions available to scripts run with pyscript. This allows those scripts to exit
back to the console's prompt instead of exiting the whole application.

0.9.7

* Bug Fixes
* Fixed bug when user chooses a zero or negative index when calling ``Cmd.select()``
* Restored behavior where ``cmd_echo`` always starts as False in a py script. This was broken in 0.9.5.
* Enhancements
* **cmdloop** now only attempts to register a custom signal handler for SIGINT if running in the main thread
* commands run as a result of ``default_to_shell`` being **True** now run via ``do_shell()`` and are saved
to history.
* Added more tab completion to pyscript command.
* Deletions (potentially breaking changes)
* Deleted ``Cmd.colorize()`` and ``Cmd._colorcodes`` which were deprecated in 0.9.5
* Replaced ``dir_exe_only`` and ``dir_only`` flags in ``path_complete`` with optional ``path_filter`` function
that is used to filter paths out of completion results.
* ``perror()`` no longer prepends "ERROR: " to the error message being printed

Page 9 of 15

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.