4.0.0b1 (2026-03-03)
Pre-release
Pre-release
Summary
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.
Details
- Breaking Changes
- Removed all use of
readlinebuilt-in module and underlying platform libraries - Deleted
cmd2.rl_utilsmodule which dealt with importing the properreadlinemodule for
each platform and provided utility functions related toreadline - Added a dependency on
prompt-toolkitand a newcmd2.pt_utilsmodule with supporting
utilities - Removed Transcript Testing feature set along with the
history -toption for generating
transcript files and thecmd2.transcriptmodule- This was an extremely brittle regression testing framework which should never have been
built into cmd2 - We recommend using pytest for unit and integration tests and
Robot Framework for acceptance tests. Both of these
frameworks can be used to create tests which are far more reliable and less brittle.
- This was an extremely brittle regression testing framework which should never have been
- Async specific:
prompt-toolkitstarts its ownasyncioevent loop in everycmd2
application- Removed
cmd2.Cmd.terminal_lockas it is no longer required to support things like
cmd2.Cmd.async_alert - Removed
cmd2.Cmd.async_refresh_promptandcmd2.Cmd.need_prompt_refreshas they are no
longer needed
- Removed
completerfunctions must now return acmd2.Completionsobject instead oflist[str].choices_providerfunctions must now return acmd2.Choicesobject instead oflist[str].- An argparse argument's
descriptive_headersfield is now calledtable_header. CompletionItem.descriptive_datais now calledCompletionItem.table_row.Cmd.default_sort_keymoved toutils.DEFAULT_STR_SORT_KEY.- Moved completion state data, which previously resided in
Cmd, into other classes.Cmd.matches_sorted->Completions.is_sortedandChoices.is_sortedCmd.completion_hint->Completions.completion_hintCmd.formatted_completions->Completions.completion_tableCmd.allow_appended_space/allow_closing_quote->Completions.allow_finalization
- Removed
Cmd.matches_delimitedsince it's no longer used. - Removed
flag_based_completeandindex_based_completefunctions since their functionality
is already provided in arpgarse-based completion. - Changed
Statement.multiline_commandfrom a string to a bool. - Made
Statement.arg_lista property which generates the list on-demand. - Renamed
Statement.outputtoStatement.redirector. - Renamed
Statement.output_totoStatement.redirect_to. - Removed
Statement.pipe_tosince it can be handled byStatement.redirectorand
Statement.redirect_to. - Changed
StatementParser.parse_command_only()to return aPartialStatementobject. - Renamed
Macro.arg_listtoMacro.args. - Removed
terminal_utils.pysinceprompt-toolkitprovides this functionality. - Replaced
async_alert()andasync_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. - Removed
Cmd.default_to_shell.
- Removed all use of
- Enhancements
- New
cmd2.Cmdparameters- auto_suggest: (boolean) if
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. - bottom toolbar: (boolean) if
True, present a persistent bottom toolbar capable of
displaying realtime status information while the prompt is displayed, see the
cmd2.Cmd2.get_bottom_toolbarmethod that can be overridden as well as the updated
getting_started.pyexample
- auto_suggest: (boolean) if
- New
cmd2.Cmdmethods- get_bottom_toolbar: populates bottom toolbar if
bottom_toolbarisTrue - get_rprompt: override to populate right prompt
- pre_prompt: hook method that is called before the prompt is displayed, but after
prompt-toolkitevent loop has started
- get_bottom_toolbar: populates bottom toolbar if
- New settables:
- max_column_completion_results: (int) the maximum number of completion results to
display in a single column
- max_column_completion_results: (int) the maximum number of completion results to
- New