Skip to content

Refactored bottom toolbar and rprompt functionality.#1700

Open
kmvanbrunt wants to merge 10 commits into
mainfrom
refactor_bottom_toolbar
Open

Refactored bottom toolbar and rprompt functionality.#1700
kmvanbrunt wants to merge 10 commits into
mainfrom
refactor_bottom_toolbar

Conversation

@kmvanbrunt

@kmvanbrunt kmvanbrunt commented Jun 27, 2026

Copy link
Copy Markdown
Member
  • Removed default implementation of get_bottom_toolbar() from Cmd class and moved it to the getting_started example.
  • Renamed bottom_toolbar flag to enable_bottom_toolbar.
  • Added enable_rprompt flag.

Also closes #1699

work the same way as get_rprompt().

Removed default implementation of get_bottom_toolbar() from Cmd class
and moved it to the getting_started example.
@kmvanbrunt kmvanbrunt requested a review from tleonhardt as a code owner June 27, 2026 15:28
@codecov

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.60%. Comparing base (df08bb7) to head (f528ab7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1700      +/-   ##
==========================================
- Coverage   99.61%   99.60%   -0.01%     
==========================================
  Files          23       23              
  Lines        5909     5894      -15     
==========================================
- Hits         5886     5871      -15     
  Misses         23       23              
Flag Coverage Δ
unittests 99.60% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@tleonhardt tleonhardt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the two very minor issues I called out, I don't have problems with the code changes per se.

However, I have a big problem with the new default behavior from a UX perspective. Before this change, when a bottom toolbar wasn't requested, there was no visual display of a bottom bar. Now, it displays an empty gray bar which is ugly, distracting, and pointless.

Please fix it so the default behavior is like it was previously.

Comment thread examples/getting_started.py
Comment thread docs/features/prompt.md
@kmvanbrunt kmvanbrunt changed the title Simplified bottom toolbar usage. Refactored bottom toolbar and rprompt functionality. Jun 27, 2026
Comment thread docs/features/initialization.md Outdated
- **disabled_commands**: commands that have been disabled from use. This is to support commands that are only available during specific states of the application. This dictionary's keys are the command names and its values are DisabledCommand objects.
- **echo**: if `True`, each command the user issues will be repeated to the screen before it is executed. This is particularly useful when running scripts. This behavior does not occur when running a command at the prompt. (Default: `False`)
- **editor**: text editor program to use with _edit_ command (e.g. `vim`)
- **enable_bottom_toolbar**: if `True`, enables a bottom toolbar while at the main prompt. (Default: `False`)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newly added enable_bottom_toolbar and enable_rprompt (as well as refresh_interval below) are documented here as instance attributes, meaning they are instance members of the cmd2.Cmd instance that developers can override at runtime. However, in cmd2.py, they are strictly initializer arguments passed directly to PromptSession and are not stored on the Cmd instance. Attempting to override them at runtime will have no effect.

I think we should create a new section documenting __init__ parameters which are not also instance attributes and move them there.

This also applies to complete_in_thread.

Alternatively, we could restore them to instance attributes stored in Cmd.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think restoring them as instance attributes is confusing since changing them after __init__() runs has no effect. If a dev wants to alter prompt behavior later, they can call self._create_main_session() with different values for these options.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean by a new section in initialization.md. That file already contains a table documenting all __init__ parameters.

Comment thread cmd2/cmd2.py
Comment thread tests/test_cmd2.py Outdated
Comment thread tests/test_cmd2.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make use of refresh_interval parameter for prompt-toolkit sessions

2 participants