@@ -299,7 +299,6 @@ def __init__(
299299 allow_redirection : bool = True ,
300300 auto_load_commands : bool = False ,
301301 auto_suggest : bool = True ,
302- bottom_toolbar : bool = False ,
303302 command_sets : Iterable [CommandSet ] | None = None ,
304303 complete_style : CompleteStyle = CompleteStyle .COLUMN ,
305304 include_ipy : bool = False ,
@@ -338,7 +337,6 @@ def __init__(
338337 must be manually installed with `register_command_set`.
339338 :param auto_suggest: If True, cmd2 will provide fish shell style auto-suggestions
340339 based on history. If False, these will not be provided.
341- :param bottom_toolbar: if ``True``, then a bottom toolbar will be displayed.
342340 :param command_sets: Provide CommandSet instances to load during cmd2 initialization.
343341 This allows CommandSets with custom constructor parameters to be
344342 loaded. This also allows the a set of CommandSets to be provided
@@ -469,7 +467,6 @@ def _(event: Any) -> None: # pragma: no cover
469467 self .history_adapter = Cmd2History (self )
470468 self .completer = Cmd2Completer (self )
471469 self .lexer = Cmd2Lexer (self )
472- self .bottom_toolbar = bottom_toolbar
473470
474471 self .auto_suggest = None
475472 if auto_suggest :
@@ -478,7 +475,7 @@ def _(event: Any) -> None: # pragma: no cover
478475 try :
479476 self .session : PromptSession [str ] = PromptSession (
480477 auto_suggest = self .auto_suggest ,
481- bottom_toolbar = self .get_bottom_toolbar if self . bottom_toolbar else None ,
478+ bottom_toolbar = self .get_bottom_toolbar ,
482479 complete_in_thread = True ,
483480 complete_style = complete_style ,
484481 complete_while_typing = False ,
@@ -493,7 +490,7 @@ def _(event: Any) -> None: # pragma: no cover
493490 # where isatty() is True but there is no real console.
494491 self .session = PromptSession (
495492 auto_suggest = self .auto_suggest ,
496- bottom_toolbar = self .get_bottom_toolbar if self . bottom_toolbar else None ,
493+ bottom_toolbar = self .get_bottom_toolbar ,
497494 complete_in_thread = True ,
498495 complete_style = complete_style ,
499496 complete_while_typing = False ,
@@ -1701,35 +1698,14 @@ def _reset_completion_defaults(self) -> None:
17011698 def get_bottom_toolbar (self ) -> list [str | tuple [str , str ]] | None :
17021699 """Get the bottom toolbar content.
17031700
1704- If self.bottom_toolbar is False, returns None .
1701+ Override this if you want a bottom toolbar to be displayed .
17051702
1706- Otherwise returns tokens for prompt-toolkit to populate in the bottom toolbar.
1703+ :return: tokens for prompt-toolkit to populate in the bottom toolbar
1704+ or None for no bottom toolbar.
17071705
17081706 NOTE: This content can extend over multiple lines. However we would recommend
17091707 keeping it to a single line or two lines maximum.
17101708 """
1711- if self .bottom_toolbar :
1712- import datetime
1713- import shutil
1714-
1715- # Get the current time in ISO format with 0.01s precision
1716- dt = datetime .datetime .now (datetime .timezone .utc ).astimezone ()
1717- now = dt .strftime ('%Y-%m-%dT%H:%M:%S.%f' )[:- 4 ] + dt .strftime ('%z' )
1718- left_text = sys .argv [0 ]
1719-
1720- # Get terminal width to calculate padding for right-alignment
1721- cols , _ = shutil .get_terminal_size ()
1722- padding_size = cols - len (left_text ) - len (now ) - 1
1723- if padding_size < 1 :
1724- padding_size = 1
1725- padding = ' ' * padding_size
1726-
1727- # Return formatted text for prompt-toolkit
1728- return [
1729- ('ansigreen' , left_text ),
1730- ('' , padding ),
1731- ('ansicyan' , now ),
1732- ]
17331709 return None
17341710
17351711 def get_rprompt (self ) -> str | FormattedText | None :
@@ -3432,7 +3408,7 @@ def get_prompt() -> ANSI | str:
34323408
34333409 return temp_session1 .prompt (
34343410 prompt_to_use ,
3435- bottom_toolbar = self .get_bottom_toolbar if self . bottom_toolbar else None ,
3411+ bottom_toolbar = self .get_bottom_toolbar ,
34363412 completer = completer_to_use ,
34373413 lexer = self .lexer ,
34383414 pre_run = self .pre_prompt ,
@@ -3442,7 +3418,7 @@ def get_prompt() -> ANSI | str:
34423418 # history is None
34433419 return self .session .prompt (
34443420 prompt_to_use ,
3445- bottom_toolbar = self .get_bottom_toolbar if self . bottom_toolbar else None ,
3421+ bottom_toolbar = self .get_bottom_toolbar ,
34463422 completer = completer_to_use ,
34473423 lexer = self .lexer ,
34483424 pre_run = self .pre_prompt ,
@@ -3461,7 +3437,7 @@ def get_prompt() -> ANSI | str:
34613437 )
34623438 line = temp_session2 .prompt (
34633439 prompt ,
3464- bottom_toolbar = self .get_bottom_toolbar if self . bottom_toolbar else None ,
3440+ bottom_toolbar = self .get_bottom_toolbar ,
34653441 pre_run = self .pre_prompt ,
34663442 rprompt = self .get_rprompt ,
34673443 )
@@ -3478,7 +3454,7 @@ def get_prompt() -> ANSI | str:
34783454 output = self .session .output ,
34793455 )
34803456 line = temp_session3 .prompt (
3481- bottom_toolbar = self .get_bottom_toolbar if self . bottom_toolbar else None ,
3457+ bottom_toolbar = self .get_bottom_toolbar ,
34823458 pre_run = self .pre_prompt ,
34833459 rprompt = self .get_rprompt ,
34843460 )
0 commit comments