Releases: python-cmd2/cmd2
Releases · python-cmd2/cmd2
2.2.0 (September 14, 2021)
- Bug Fixes
- Fixed extra space appended to each alias by "alias list" command
- Enhancements
- New function
set_default_ap_completer_type()allows developer to extend and modify the
behavior ofArgparseCompleter. - Added
ArgumentParser.get_ap_completer_type()andArgumentParser.set_ap_completer_type(). These
methods allow developers to enable custom tab completion behavior for a given parser by using a custom
ArgparseCompleter-based class. - Added
ap_completer_typekeyword arg toCmd2ArgumentParser.__init__()which saves a call
toset_ap_completer_type(). This keyword will also work withadd_parser()when creating subcommands
if the base command's parser is aCmd2ArgumentParser. - New function
register_argparse_argument_parameter()allows developers to specify custom
parameters to be passed to the argparse parser'sadd_argument()method. These parameters will
become accessible in the resulting argparse Action object when modifyingArgparseCompleterbehavior. - Using
SimpleTablein the output for the following commands to improve appearance.- help
- set (command and tab completion of Settables)
- alias tab completion
- macro tab completion
- Tab completion of
CompletionItemsnow includes divider row comprised ofCmd.rulercharacter. - Removed
--verboseflag from set command since descriptions always show now. - All cmd2 built-in commands now populate
self.last_result. - Argparse tab completer will complete remaining flag names if there are no more positionals to complete.
- Updated
async_alert()to account forself.promptnot matching Readline's current prompt.
- New function
- Deletions (potentially breaking changes)
- Deleted
set_choices_provider()andset_completer()which were deprecated in 2.1.2
- Deleted
- Breaking Changes
- Renamed
set_default_argument_parser()toset_default_argument_parser_type()
- Renamed
2.1.2 (July 5, 2021)
- Enhancements
- Added the following accessor methods for cmd2-specific attributes to the
argparse.Actionclassget_choices_callable()set_choices_provider()set_completer()get_descriptive_header()set_descriptive_header()get_nargs_range()set_nargs_range()get_suppress_tab_hint()set_suppress_tab_hint()
- Added the following accessor methods for cmd2-specific attributes to the
- Deprecations
- Now that
set_choices_provider()andset_completer()have been added as methods to the
argparse.Actionclass, the standalone functions of the same name will be removed in version
2.2.0. To update to the new convention, do the following:- Change
set_choices_provider(action, provider)toaction.set_choices_provider(provider) - Change
set_completer(action, completer)toaction.set_completer(completer)
- Change
- Now that
2.1.1 (June 17, 2021)
- Bug Fixes
- Fixed handling of argparse's default options group name which was changed in Python 3.10
- Enhancements
- Restored
pluginsandtests_isolateddirectories to tarball published to PyPI forcmd2release
- Restored
2.1.0 (June 14, 2021)
- Enhancements
- Converted persistent history files from pickle to compressed JSON
2.0.1 (June 7, 2021)
- Bug Fixes
- Exclude
pluginsandtests_isolateddirectories from tarball published to PyPI forcmd2release
- Exclude
2.0.0 (June 6, 2021)
- 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
cmd22.0 supports Python 3.6+ (removed support for Python 3.5)- Argparse Completion / Settables
- Replaced
choices_function/choices_methodwithchoices_provider. - Replaced
completer_function/completer_methodwithcompleter. - ArgparseCompleter now always passes
cmd2.CmdorCommandSetinstance as the first positional
argument to choices_provider and completer functions.
- Replaced
- Moved
basic_completefrom utils intocmd2.Cmdclass. - Moved
CompletionErrorto exceptions.py Namespace.__statement__has been removed. UseNamespace.cmd2_statement.get()instead.- Removed
--silentflag fromalias/macro createsince startup scripts can be run silently. - Removed
--with_silentflag fromalias/macro listsince startup scripts can be run silently. - Removed
with_argparser_and_unknown_argssince it was deprecated in 1.3.0. - Renamed
silent_startup_scripttosilence_startup_scriptfor clarity. - Replaced
cmd2.Cmd.completion_headerwithcmd2.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.settablesis 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_ipythonkeyword parameter ofcmd2.Cmd.__init__()toinclude_ipy. pycommand is only enabled ifinclude_pyparameter isTrue. See Enhancements for a description
of this parameter.- Removed ability to run Python commands from the command line with
py. Nowpytakes 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_sigintflag, which whenTrue, 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 for an example. - Added
cmd2.exceptions.PassThroughExceptionto raise unhandled command exceptions instead of printing them. - Added support for ANSI styles and newlines in tab completion results using
cmd2.Cmd.formatted_completions.
cmd2provides this capability automatically if you return argparse completion matches asCompletionItems. - 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.
- Settables may be optionally scoped to a CommandSet. Settables added to CommandSets will appear when a
- Raising
SystemExitor callingsys.exit()in a command or hook function will setself.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_localsin the IPython environment - Added
include_pykeyword parameter tocmd2.Cmd.__init__(). IfFalse, then thepycommand will
not be available. Defaults toFalse.run_pyscriptis 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 methodcmd2.Cmd.run_editor()
- Added support for custom tab completion and up-arrow input history to
Plugin: External Test 2.0.0 (June 7, 2021)
Version update to match Cmd2 2.0 release.
No changes to plugin.
1.5.0 (January 31, 2021)
- Bug Fixes
- Fixed bug where setting
always_show_hint=Truedid not show a hint when completingSettables - 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
FileNotFoundErrorwhich occurred when runninghistory --clearand no history file existed.
- Fixed bug where setting
- Enhancements
- Added
silent_startup_scriptoption tocmd2.Cmd.__init__(). IfTrue, 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
- Added
- Notes
- This is the last release planned to support Python 3.5
1.4.0 (November 11, 2020)
- 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 (October 1, 2020)
- 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_todecorator resulted in duplicated help text in the base command the subcommands belong to.