4.0.0-b3 (2026-04-18)
Pre-release
Pre-release
What's Changed
Same as 4.0.0b2 other than:
- Breaking Changes
- All parsers used with
cmd2commands must be an instance ofCmd2ArgumentParseror a child
class of it. - Removed
set_ap_completer_type()andget_ap_completer_type()sinceap_completer_typeis
now a public member ofCmd2ArgumentParser. - Moved
set_parser_prog()toCmd2ArgumentParser.update_prog(). - Renamed
cmd2_handlertocmd2_subcmd_handlerin theargparse.Namespacefor clarity. - Removed
Cmd2AttributeWrapperclass.argparse.Namespaceobjects passed to command functions
now contain direct attributes forcmd2_statementandcmd2_subcmd_handler. - Renamed
cmd2/command_definition.pytocmd2/command_set.py. - Removed
Cmd.doc_headerand thewith_default_categorydecorator. Help categorization is now
driven by theDEFAULT_CATEGORYclass variable (see Simplified command categorization in
the Enhancements section below for details). - Removed
Cmd.undoc_headersince all commands are now considered categorized. - Renamed
Cmd.cmd_func()toCmd.get_command_func(). cmd2no longer sets a default title for a subparsers group. If you desire a title, you will
need to pass one in like thisparser.add_subparsers(title="subcommands"). This is standard
argparsebehavior.TextGroupis now a standalone Rich renderable.- Removed
formatter_creatorparameter fromTextGroup.__init__(). - Removed
Cmd2ArgumentParser.create_text_group()method.
- Removed
argparseandRichintegration refactoring:- Renamed
argparse_custommodule toargparse_utils. - Moved the following classes from
argparse_utilstorich_utils:Cmd2HelpFormatterArgumentDefaultsCmd2HelpFormatterMetavarTypeCmd2HelpFormatterRawDescriptionCmd2HelpFormatterRawTextCmd2HelpFormatterTextGroup
- Replaced the global
APP_THEMEconstant inrich_utils.pywithget_theme()and
set_theme()functions to support lazy initialization and safer in-place updates of the
theme.
- Renamed
- All parsers used with
- Enhancements
- New
cmd2.Cmdmethods- ppretty: a cmd2-compatible replacement for
rich.pretty.pprint()
- ppretty: a cmd2-compatible replacement for
- Simplified command categorization:
- By default, all commands in a class are grouped under its
DEFAULT_CATEGORY. - Individual commands can still be manually moved using the
with_category()decorator. - For more details and examples, see the Help documentation and the
examples/default_categories.pyfile.
- By default, all commands in a class are grouped under its
CommandSetis now a generic class, which allows developers to parameterize it with their
specificcmd2.Cmdsubclass (e.g.,class MyCommandSet(CommandSet[MyApp]):). This provides
full type hints and IDE autocompletion forself._cmdwithout needing to override and cast
the property.
- New
Full Changelog: 4.0.0-b2...4.0.0-b3