NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #3646 most downloaded on PyPI
cmd2 - quickly build feature-rich and user-friendly interactive command line applications in Python
Last release 26 days ago
08 Sep 2026
Ships fairly regularly
a new release about every 3 weeks
Nearly every release is documented
notes for 60 of the last 60 stable releases
1 version withdrawn
withdrawn after publishing
19 years old
174 releases · first in 2008
uv run does its own sync of the project env with default groups by @tleonhardt in #1746
Full Changelog: 4.2.3...4.2.4
UnicodeEncodeError and leaving an empty file
behind. Command output is rendered by Rich and contains box-drawing characters, which no
cp125x Windows ANSI code page can represent, so redirecting or piping it failed. This
affects current Windows 11 with default settings on Python 3.11 through 3.14, not only older
systems. Redirection targets and pipes now use UTF-8 explicitlyOne column per quarter.
Fix ty unresolved-attribute warnings and add mypy back by @tleonhardt in #1737
Full Changelog: 4.2.2...4.2.3
BoundCommandFunc and UnboundCommandFunc TypeAliases in types.py to Protocol
classes for stricter type checking on cmd2 command method referencesImproved documentation in attempt at making some recommended best-practices more discoverable
cmd_as_argument exampleAdded bracketed paste support so multiple pasted commands execute sequentially and multiline commands continue as expected.
@with_annotated argument groups can now contain an ArgumentBlock 's arguments. A Group member names a command-line argument, and a block expands into
@with_annotated argument groups can now contain an ArgumentBlock's arguments. A Group member names a command-line argument, and a block expands into one argument per field, so its fields are named: Group("host", "port").Group member now names an argument rather than a parameter. The two differ only for an ArgumentBlock parameter, which is expanded away and has no argument of its own: Group("conn") now raises ValueError pointing at the block's fields. It previously produced an empty argument group in groups= and a KeyError in mutually_exclusive_groups=.Group member exists is now validated when the parser is built rather than at decoration time, because a block's field names cannot be known without resolving its type hint, and resolving hints eagerly would break forward-referenced annotations. A typo in a member name still raises ValueError, but on first use of that command rather than at class definition. The spec-shape rules (a member listed twice, a member in two groups, required=True on a plain group, the mutex nesting rules) are unaffected and still hard-fail at decoration time.@with_annotated(base_command=True) not listing its subcommands under the positional arguments section of the parent command's --help, unlike argparse and Cmd2ArgumentParser. They were placed in an untitled section of their own instead. Passing subcommand_title or subcommand_description still gives the subcommands a dedicated section (#1715).@with_annotated decorator so using ArgumentBlock works with groups (#1718).choices_provider results were being re-sorted (#1727).Updated getting_started.py example to remove multi-line command usage by @tleonhardt in #1713
Full Changelog: 4.1.1...4.1.2
Settableipython import which slowed application startup timeFixed mypy 2.2.0 failures by @tleonhardt in #1709
Full Changelog: 4.1.0...4.1.1
mypy 2.2.0Renamed the bottom_toolbar argument in Cmd.__init__() to enable_bottom_toolbar . It is also now strictly an __init__ parameter and not an instance att
bottom_toolbar argument in Cmd.__init__() to enable_bottom_toolbar. It is also now strictly an __init__ parameter and not an instance attribute.complete_in_thread is now strictly an __init__ parameter and not an instance attribute of Cmd.get_rprompt() is now only called if the enable_rprompt argument in Cmd.__init__() is set to True.with_annotated no longer trigger spurious mypy errors and preserve their original signature.cmd2.Cmd parameters
True, then completion will run in a separate thread. If False then completion runs in the main thread and causes it to block if slow. Defaults to True.@with_argparser and @with_argument_block decorators for parsing command arguments@with_annotated now supports frozenset[T] collection parameters, alongside the existing list[T], set[T], and tuple[T, ...] collection types.@with_annotated mutually exclusive groups now accept a title/description to render the group as a titled help section (argparse's one supported nesting, a mutex inside an argument group), declared in one place with no paired groups= entry.@with_annotated now validates groups / mutually_exclusive_groups specs eagerly at decoration time, so a misconfigured group (a member that names no parameter, a parameter placed in two groups, a mutex group spanning or partially overlapping argument groups, a titled section declared in two places, or Group(required=True) on a plain group) hard-fails when the class is defined instead of being deferred to first command use where the error was swallowed. The checks read parameter names only, so forward-referenced annotations still decorate cleanly.Argument/Option accept a new allow_unknown_entry flag for Enum parameters. When set, a command-line token matched by neither a member value nor name is routed through the enum's own _missing_ hook, so an enum can resolve aliases, alternate spellings, or special keywords. A token that _missing_ declines (returns None) is still rejected.@with_annotated now supports a union of Enum subclasses (e.g. EnumA | EnumB). Each member keeps its own converter and a token resolves to the first member that accepts it, so when two members share a representation the earlier one in the union wins. A member whose _missing_ raises on a token declines it (the next member is still tried) rather than aborting the union, and a merged "choose from ..." error is raised only when every member declines. Unions containing a Literal or any non-Enum member are still rejected as ambiguous.Argument/Option accept new converter and preprocess hooks for custom string conversion, giving @with_annotated parity with a hand-built add_argument(type=...) (a raw type= in the metadata is still rejected). converter is a Callable[[str], Any] that replaces the inferred type= converter; because it owns the conversion, the annotation may be any type (an otherwise unsupported type like datetime, or an otherwise-ambiguous multi-member union like int | str, becomes legal) and the inferred choices/completer are dropped. preprocess is a Callable[[str], str] that runs before the inferred converter, transforming the raw token while keeping the inferred type=/choices/completer (e.g. preprocess=str.lower on an Enum). The two are mutually exclusive on one parameter and neither may be combined with a value-less action.@with_annotated now supports reusable argument blocks: a parameter typed with a @dataclass that subclasses the new cmd2.ArgumentBlock trait expands each field into a flat command-line argument, and the parsed values are reconstructed into a dataclass instance passed to the command, letting several commands reuse the same fields without duplication. See the annotated documentation.cmd2_base_args / cmd2_parent_args parameters, passing parent-level options down without redeclaring them.Nothing published for this version
Added common_prefix method to cmd2.string_utils module as a replacement for os.path.commonprefix since that is now deprecated in Python 3.15
cmd2 now has a dependency on prompt-toolkit which serves as a pure-Python cross-platform replacement for GNU Readline. Previously, cmd2 had used different readline dependencies on each Operating System (OS) which was at times a very frustrating developer and user experience due to small inconsistencies in these different readline libraries. Now we have consistent cross-platform support for tab-completion, user terminal input, and history. Additionally, this opens up some cool advanced features such as support for syntax highlighting of user input while typing, auto-suggestions similar to those provided by the fish shell, and the option for a persistent bottom bar that can display realtime status updates while the prompt is displayed.
readline built-in module and underlying platform librariescmd2.rl_utils module which dealt with importing the proper readline module for each platform and provided utility functions related to readlineprompt-toolkit and a new cmd2.pt_utils module with supporting utilitiescmd2 now requires Python 3.11 or laterhistory -t option for generating transcript files and the cmd2.transcript module
prompt-toolkit starts its own asyncio event loop in every cmd2 application
cmd2.Cmd.terminal_lock as it is no longer required to support things like cmd2.Cmd.async_alertcmd2.Cmd.async_refresh_prompt and cmd2.Cmd.need_prompt_refresh as they are no longer neededcompleter functions must now return a cmd2.Completions object instead of list[str].choices_provider functions must now return a cmd2.Choices object instead of list[str].descriptive_headers field is now called table_columns.CompletionItem.descriptive_data is now called CompletionItem.table_data.DEFAULT_DESCRIPTIVE_HEADERS. This means you must define table_columns when using CompletionItem.table_data data.Cmd.default_sort_key moved to utils.DEFAULT_STR_SORT_KEY.Cmd, into other classes.
Cmd.matches_sorted -> Completions.is_sorted and Choices.is_sortedCmd.completion_hint -> Completions.hintCmd.formatted_completions -> Completions.table (Now a Rich Table)Cmd.allow_appended_space/allow_closing_quote -> Completions.allow_finalizationCmd.matches_delimited since it's no longer used.flag_based_complete and index_based_complete functions since their functionality is already provided in arpgarse-based completion.Statement.multiline_command from a string to a bool.Statement.arg_list a property which generates the list on-demand.Statement.output to Statement.redirector.Statement.output_to to Statement.redirect_to.Statement.pipe_to since it can be handled by Statement.redirector and Statement.redirect_to.StatementParser.parse_command_only() to return a PartialStatement object.Macro.arg_list to Macro.args.terminal_utils.py since prompt-toolkit provides this functionality.async_alert() and async_update_prompt() with a single function called add_alert(). This new function is thread-safe and does not require you to acquire a mutex before calling it like the previous functions did.Cmd.default_to_shell.Cmd.ruler since cmd2 no longer uses it.cmd2 commands must be an instance of Cmd2ArgumentParser or a child class of it.set_default_argument_parser_type() to set_default_argument_parser().set_default_ap_completer_type() to set_default_argparse_completer().set_ap_completer_type() and get_ap_completer_type() since completer_class is now a public member of Cmd2ArgumentParser.set_parser_prog() to Cmd2ArgumentParser.update_prog().cmd2_handler to cmd2_subcommand_func in the argparse.Namespace for clarity.Cmd2AttributeWrapper class. argparse.Namespace objects passed to command functions now contain direct attributes for cmd2_statement and cmd2_subcommand_func.cmd2/command_definition.py to cmd2/command_set.py.Cmd.doc_header and the with_default_category decorator. Help categorization is now driven by the DEFAULT_CATEGORY class variable (see Simplified command categorization in the Enhancements section below for details).Cmd.undoc_header since all commands are now considered categorized.Cmd.cmd_func() to Cmd.get_command_func().cmd2 no longer sets a default title for a subparsers group. If you desire a title, you will need to pass one in like this parser.add_subparsers(title="subcommands"). This is standard argparse behavior.TextGroup now implements HelpFormatterRenderable (see Enhancements section below for more details).
formatter_creator parameter from TextGroup.__init__().Cmd2ArgumentParser.create_text_group() method.argparse and Rich integration refactoring:
argparse_custom module to argparse_utils.argparse_utils to rich_utils:
Cmd2HelpFormatterArgumentDefaultsCmd2HelpFormatterMetavarTypeCmd2HelpFormatterRawDescriptionCmd2HelpFormatterRawTextCmd2HelpFormatterTextGroupAPP_THEME constant in rich_utils.py with get_theme(), reset_theme(), and update_theme() functions in theme.py to support lazy initialization and safer in-place updates of the theme.Cmd._command_parsers to Cmd.command_parsers.RichPrintKwargs TypedDict in favor of using Mapping[str, Any], allowing for greater flexibility in passing keyword arguments to console.print() calls.always_show_hint settable as it provided a poor user experience with prompt-toolkitcmd2 redirection only captures output directed to self.stdout (e.g., via self.poutput()). Standard print() calls write directly to sys.stdout and are not captured. However, print() calls within pyscripts and the interactive Python shell are treated as command output and sent to self.stdout, allowing them to be captured.feedback_to_output settable and changed cmd2.Cmd.pfeedback to always print to self.stdoutCmd.parseline() since it was unused and merely wrapped StatementParser.parse_command_only().cmd2.Cmd parameters
True, provide fish shell style auto-suggestions. These are grayed-out hints based on history. User can press right-arrow key to accept the provided suggestion.True, present a persistent bottom toolbar capable of displaying realtime status information while the prompt is displayed, see the cmd2.Cmd2.get_bottom_toolbar method that can be overridden as well as the updated getting_started.py examplecmd2.Cmd methods
bottom_toolbar is Trueprompt-toolkit event loop has startedrich.pretty.pprint()cmd2.Cmd.select has been revamped to use the choice function from prompt-toolkit when both stdin and stdout are TTYsargparse changescommon_prefix method to cmd2.string_utils module as a replacement for os.path.commonprefix since that is now deprecated in Python 3.15DEFAULT_CATEGORY.with_category() decorator.examples/default_categories.py file.CommandSet is now a generic class, which allows developers to parameterize it with their specific cmd2.Cmd subclass (e.g.,class MyCommandSet(CommandSet[MyApp]):). This provides full type hints and IDE autocompletion for self._cmd without needing to override and cast the property.traceback_kwargs attribute to allow customization of Rich-based tracebacks.HelpFormatterRenderable protocol and HelpContent type alias to support context-aware help content in argparse.print() function available in a pyscript writes to self.stdout and respects the allow_style setting. It also supports printing Rich objects.Cmd2ArgumentParser.output_to() context manager to temporarily set the output stream during argparse operations. This is helpful for directing output for functions like parse_args(), which default to sys.stdout and lack a file argument.prompt-toolkit completion menu colors by overriding the following fields in the cmd2 theme:
Cmd2Style.COMPLETION_MENU - Base style for the entire completion menu container (sets the background)Cmd2Style.COMPLETION_MENU_COMPLETION -Style for an individual, non-selected completion itemCmd2Style.COMPLETION_MENU_CURRENT - Style for the currently selected completion itemCmd2Style.COMPLETION_MENU_META - Style for "meta" information shown alongside a completionCmd2Style.COMPLETION_MENU_META_CURRENT- Style for meta info of current itemset command to consolidate its confirmation output into a single, colorized line. The confirmation now uses pfeedback(), allowing it to be silenced when the quiet settable is enabled.alias and macro subcommands for create and delete now output their non-essential success case output using pfeedback@with_annotated decorator, a type-hint-driven alternative to @with_argparse that builds the parser automatically from a command's signature (positional/option inference, enum/literal/path/collection handling, subcommands, groups, mutex). See the annotated_example.py example for demonstration of usage.
cmd2 command parameters using type hints using syntax essentially identical to that used by Typer@with_annotated decorator builds an argparse parser for youfeat: Experimental annotated argparse by @KelvinChung2000 in #1666
set_default_argument_parser_type() to set_default_argument_parser().set_default_ap_completer_type() to set_default_argparse_completer().cmd2_subcmd_handler to cmd2_subcommand_func in the argparse.Namespace for clarity.Full Changelog: 4.0.0-rc1...4.0.0-rc2
Add styles to theme for prompt-toolkit completion styles by @tleonhardt in #1653
feedback_to_output settable and made pfeedback() consistent by @bambu in #1647_cmd_app and remove legacy parseline() method by @kmvanbrunt in #1659traceback_width a Settable.Full Changelog: 4.0.0-b6...4.0.0-rc1
Quick fixes 4.x by @kmvanbrunt in #1651
always_show_hint settable as it provided a poor user experience withprompt-toolkitcmd2 redirection only captures output directed to self.stdout (e.g., viaself.poutput()). Standard print() calls write directly to sys.stdout and are notprint() calls within pyscripts and the interactive Python shell areself.stdout, allowing them to be captured.HelpFormatterRenderable protocol and HelpContent type alias to support context-awareargparse.print() function available in a pyscript writes to self.stdout and respects theallow_style setting. It also supports printing Rich objects.Cmd2ArgumentParser.output_to() context manager to temporarily set the output streamargparse operations. This is helpful for directing output for functions likeparse_args(), which default to sys.stdout and lack a file argument.ArgparseCompleter.print_help() not passing file stream to recursive call.constants.REDIRECTION_TOKENS was being mutated.Full Changelog: 4.0.0-b5...4.0.0-b6
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Fixed ArgparseCompleter.print_help() not passing file stream to recursive call.
ArgparseCompleter.print_help() not passing file stream to recursive call.constants.REDIRECTION_TOKENS was being mutated.Fixed issue where Rich stripped colors from text in test environments where TERM=dumb.
Moved cmd2-specific printing logic from Cmd.print_to() into Cmd2BaseConsole.print() and Cmd2BaseConsole.log(). This removes need to pass a console obj
Enhancements
Cmd.print_to() into Cmd2BaseConsole.print() and
Cmd2BaseConsole.log(). This removes need to pass a console object to Cmd.print_to().rich.console.Console where complex renderables (like Table and Rule)
may not receive formatting settings passed to console.print() and console.log().Breaking Changes
destination parameter of Cmd.print_to() back to file since you can no longer
pass in a console.Added ability to pass a console object to Cmd.print_to(). This provides support for things like wrapping a print_to() call in a console.status() or co
Enhancements
Cmd.print_to(). This provides support for things
like wrapping a print_to() call in a console.status() or console.capture() context
manager.Breaking Changes
file parameter of Cmd.print_to() to destination to support file-like objects
and console objects.Cmd2BaseConsole(file) argument is now a keyword-only argument to be consistent with the
rich.console.Console class.Updated rich_utils.ANSI_STYLE_SEQUENCE_RE to only match ANSI SGR (Select Graphic Rendition) sequences for text styling. It previously also matched DEC
rich_utils.ANSI_STYLE_SEQUENCE_RE to only match ANSI SGR (Select Graphic Rendition)
sequences for text styling. It previously also matched DEC Private Mode sequences.The async_alert and async_prompt_update methods of cmd2.Cmd now respect the current value of the allow_style settable
async_alert and async_prompt_update methods of cmd2.Cmd now respect the current
value of the allow_style settable
allow_style is NEVER, all style-related ANSI escape codes will be stripped to
ensure plain text outputFixed incompatibilities with Python 3.14.3.
Bug Fixes
Potentially Breaking Changes
Fixed issue where delimiter_complete() could cause more matches than display matches
delimiter_complete() could cause more matches than display matchesCommandSet registration did not respect disabled categoriesFixed missing typing-extensions dependency for Python 3.10
typing-extensions dependency for Python 3.10Fixed bug where rich-argparse was not coloring cmd2's custom nargs formatting
rich-argparse was not coloring cmd2's custom nargs formattingcmd2 no longer has a dependency on cmd and cmd2.Cmd no longer inherits from cmd.Cmd
cmd2 no longer has a dependency on cmd and cmd2.Cmd no longer inherits from cmd.Cmd
argparse_custom module breaking changes:
cmd2 now has a dependency on rich for rich text and pretty
formatting in the terminal. Previously, cmd2 had a large amount of custom code for this purpose
that predated the existence of rich. This opens the door to even more beautiful cmd2
applications. To get the most out of the new capabilities, we encourage you to spend a little bit of
time reading the rich documentation.
Breaking Changes
table_creator.py module in favor of rich tables (see the
rich_tables.py
example for more info)utils.py to a new string_utils.py module
string from some of the names so quote_string is now just
quote and quote_string_if_needed is now quote_if_neededansi.py into string_utils.pyansi.py with modern rich stylesansi.py to terminal_utils.py to better reflect its purposecmd2 now requires Python 3.10 or laterSettable.get_value() and Settable.set_value() methods with a more Pythonic
value propertyprog value in the with_argparser() decorator, as
this is now handled centrally in Cmd._build_parser()auto_load_commands argument to cmd2.Cmd.__init__ now defaults to Falseargparse_custom module breaking changes:
descriptive_header: str replaced with descriptive_headers: Sequence[str | rich.Column]
set_descriptive_headers and get_descriptive_headersCompletionItem.description: str changed to
CompletionItem.descriptive_data: Sequence[str | rich.Column]decorators module breaking changes:
_set_parser_prog renamed to set_parser_prog (without the leading underscore) and moved
to argparse_custom module--output_file to --output-file to follow common command-line practicescmd2.Cmd.ppretty method removed - rich has more and better options for pretty printing,
see the
pretty_print.py
example for a demonstration of pretty-printing JSON dataEnhancements
poutput(), perror(), ppaged(), etc.) to natively render
rich objects, enabling beautiful and complex outputcmd2's built-in commands. See the
custom_parser.py
example for an updated guideCmd.macro_arg_complete() for tab-completing macro arguments, with default path
completion that can be easily customizedcolors.py and styles.py to provide easy access to rich color names and manage
cmd2-specific style definitions using StrEnum (see the
colors.py example for a
demonstration of all colors available to your cmd2 application)cmd2 application using rich_utils.set_theme
(see the rich_theme.py
example for more info)stty sane
with termios.tcsetattrBug Fixes
cmd2 could unintentionally overwrite an application's
sys.stdoutMigration Aids - these will help you iteratively migrate to cmd2 3.x in stages
cmd2.ansi module present in cmd2 2.7.0cmd2.table_creator module present in cmd2 2.7.0Nothing published for this version
Nothing published for this version
Nothing published for this version
Integrated rich-argparse with cmd2's default argparse help formatter (Cmd2HelpFormatter).
Cmd2HelpFormatter).Added explicit support for free-threaded versions of Python, starting with version 3.14
Enhancements
Bug Fixes
prog value in the with_argparser decorator. This is to
preserve backward compatibility in the cmd2 2.0 family. This functionality will be removed
in cmd2 3.0.0.Fixed bug that prevented cmd2 from working with from __future__ import annotations
cmd2 from working with from __future__ import annotationscmd2 2.6 supports Python 3.9+ (removed support for Python 3.8)
cmd2 2.6 supports Python 3.9+ (removed support for Python 3.8)Cmd.ppretty() method for pretty printing arbitrary Python data structures-t/--transcript argument to the history commandFixed duplicated parameter tables in API documentation.
Fixed docstring style for MkDocs API documentation so parameters are displayed properly.
Fixed 'index out of range' error when passing no arguments to an argparse-based command function.
Rolled back undocumented changes to printing functions introduced in 2.5.0.
Fixed issue where argument parsers for overridden commands were not being created.
Cmd.ppaged() was not writing to the passed in destination.Fixed type hint for with_default_category decorator which caused type checkers to mistype a subclass of CommandSet as a plain CommandSet.
with_default_category decorator which caused type checkers to mistype a
subclass of CommandSet as a plain CommandSet.Fixed type hints for passing a class method to with_argparser and as_subcommand_to.
with_argparser and as_subcommand_to.set command was not always printing a settable's current value.Fixed ZeroDivisionError in async_alert() when shutil.get_terminal_size().columns is 0.
ZeroDivisionError in async_alert() when shutil.get_terminal_size().columns is 0.Changed CommandSet._cmd to a read-only property which never returns None because it is meant to be called after the CommandSet is registered. This add
CommandSet._cmd to a read-only property which never returns None because it is
meant to be called after the CommandSet is registered. This addresses type checker errors
that occurred if CommandSet._cmd wasn't cast or checked if None before use.Fixed default pytest execution when not using cmd2's custom invoke command via inv pytest
pytest execution when not using cmd2's custom invoke command via
inv pytestFixed readline bug when using ipy command with gnureadline and Python 3.13
ipy command with gnureadline and Python 3.13Deletions (potentially breaking changes)
cmd2 2.5 supports Python 3.8+ (removed support for Python 3.6 and 3.7)async_alert() overwrites readline's incremental and non-incremental search
prompts.
Cmd.need_prompt_refresh() and
Cmd.async_refresh_prompt().attrs and replaced with
dataclassesallow_clipboard initialization parameter and attribute to disable ability to add output
to the operating system clipboardscripts_add_to_history which determines whether scripts and pyscripts
add commands to history.apply_style from Cmd.pwarning().Fixed ValueError caused when passing Cmd.columnize() strings wider than display_width.
Cmd.columnize() strings wider than display_width.utils.str_to_bool() -> utils.to_bool().utils.to_bool() so that it accepts and converts bool, int, and float in
addition to str.Updated argparse decorator to remove annotations when the docstring is used for a command's help text.
Fixed value for ansi.Bg.YELLOW.
ansi.Bg.YELLOW.ansi.allow_style.async_alert() raises a RuntimeError if called from the main thread.Deletions (potentially breaking changes)
ansi.async_alert_str() which would raise IndexError if prompt was blank.pyperclip.PassThroughException to __init__.py imports.cmd2.fg and cmd2.bg which were deprecated in 2.3.0. Use cmd2.Fg and cmd2.Bg
instead.Added clearer exception handling to BorderedTable and SimpleTable.
BorderedTable and SimpleTable.Fixed issue where a ns_provider could be passed None instead of its correct cmd2.Cmd or CommandSet value.
ns_provider could be passed None instead of its correct cmd2.Cmd or
CommandSet value.Fixed issue introduced in 2.3.0 with AlternatingTable, BorderedTable, and SimpleTable that caused header alignment settings to be overridden by data a
AlternatingTable, BorderedTable, and SimpleTable
that caused header alignment settings to be overridden by data alignment settings.CompletionItems now saves the original object from which it creates a string.CompletionItems as argparse choices is fully supported. cmd2 patched argparse to
compare input to the original value instead of the CompletionItems instance.ArgparseCompleter now does the following if a list of CompletionItems was created with
numerical types:
Deprecated cmd2.fg. Use cmd2.Fg instead.
AttributeError in rl_get_prompt() when prompt is None.select() converts return values to strings. It
should never have converted return values.AlternatingTable, BorderedTable, and
SimpleTable.cmd2.EightBitFg and cmd2.EightBitBg classes.cmd2.RgbFg and cmd2.RgbBg classes.ansi.allow_style from a string to an ansi.AllowStyle Enum class.cmd2.fg. Use cmd2.Fg instead.cmd2.bg. Use cmd2.Bg instead.ansi.FgColor or
ansi.BgColor. Therefore, ansi.style() no longer accepts colors as strings.Deletions (potentially breaking changes)
set_default_ap_completer_type() allows developer to extend and modify the
behavior of ArgparseCompleter.ArgumentParser.get_ap_completer_type() and ArgumentParser.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.ap_completer_type keyword arg to Cmd2ArgumentParser.__init__() which saves a call to
set_ap_completer_type(). This keyword will also work with add_parser() when creating
subcommands if the base command's parser is a Cmd2ArgumentParser.register_argparse_argument_parameter() allows developers to specify custom
parameters to be passed to the argparse parser's add_argument() method. These parameters
will become accessible in the resulting argparse Action object when modifying
ArgparseCompleter behavior.SimpleTable in the output for the following commands to improve appearance.
CompletionItems now includes divider row comprised of Cmd.ruler
character.--verbose flag from set command since descriptions always show now.self.last_result.async_alert() to account for self.prompt not matching Readline's current prompt.set_choices_provider() and set_completer() which were deprecated in 2.1.2set_default_argument_parser() to set_default_argument_parser_type()Added the following accessor methods for cmd2-specific attributes to the argparse.Action class
argparse.Action
class
get_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()set_choices_provider() and set_completer() have been added as methods to the
argparse.Action class, the standalone functions of the same name will be removed in version
2.2.0. To update to the new convention, do the following:
set_choices_provider(action, provider) to action.set_choices_provider(provider)set_completer(action, completer) to action.set_completer(completer)Fixed handling of argparse's default options group name which was changed in Python 3.10
plugins and tests_isolated directories to tarball published to PyPI for cmd2
releaseYour coding agent can read these notes before it upgrades. Set up the MCP server →