Skip to content

Commit c91103e

Browse files
committed
Updated CHANGELOG.md with info on all new cmd2.Cmd parameters
1 parent d5c8d2e commit c91103e

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

CHANGELOG.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,25 @@ shell, and the option for a persistent bottom bar that can display realtime stat
2828
- Removed `cmd2.Cmd.async_refresh_prompt` and `cmd2.Cmd.need_prompt_refresh` as they are no
2929
longer needed
3030
- Enhancements
31-
- New optional persistent **bottom toolbar** capable of displaying realtime status information,
32-
see the `bottom_toolbar` optional argument to the initializer for `cmd2.Cmd` and the
33-
`cmd2.Cmd2.get_bottom_toolbar` method that can be overridden as well as the updated
34-
`getting_started.py` example
31+
- New `cmd2.Cmd` parameters
32+
- **auto_suggest**: (boolean) if `True`, provide fish shell style auto-suggestions. These
33+
are grayed-out hints based on history. User can press right-arrow key to accept the
34+
provided suggestion.
35+
- **bottom toolbar**: (boolean) if `True`, present a persistent bottom toolbar capable of
36+
displaying realtime status information while the prompt is displayed, see the
37+
`cmd2.Cmd2.get_bottom_toolbar` method that can be overridden as well as the updated
38+
`getting_started.py` example
39+
- **complete_style**: (enum) style of prompt-toolkit tab completion to use, 3 valid options
40+
are:
41+
- 1. `CompleteStyle.COLUMN` (default) - displays hints with help next to them in one
42+
big column
43+
- 2. `CompleteStyle.MULTI_COLUMN` - displays hints across multiple columns, with help
44+
when selected
45+
- 3. `CompleteStyle.READLINE_LIKE` - displays like readline; WARNING:
46+
`complete_in_thread` doesn't work for background completion when this option is
47+
selected
48+
- **max_column_completion_items**: (int) the maximum number of completion results to display
49+
in a single column, used to provide the initial value for a settable with the same name
3550
- Added `cmd2.Cmd._in_prompt` flag that is set to `True` when the prompt is displayed and the
3651
application is waiting for user input
3752
- Added `cmd2.Cmd.pre_prompt` hook method that is called before the prompt is displayed, but

cmd2/cmd2.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def __init__(
351351
:param include_py: should the "py" command be included for an embedded Python shell
352352
:param intro: introduction to display at startup
353353
:param max_column_completion_items: The maximum number of completion results to display in a single column,
354-
used to provide the initial value for a settable with the same name.
354+
used to provide the initial value for a settable with the same name
355355
:param multiline_commands: list of commands allowed to accept multi-line input
356356
:param persistent_history_file: file path to load a persistent cmd2 command history from
357357
:param persistent_history_length: max number of history items to write
@@ -478,6 +478,7 @@ def _(event: Any) -> None: # pragma: no cover
478478
try:
479479
self.session: PromptSession[str] = PromptSession(
480480
auto_suggest=self.auto_suggest,
481+
bottom_toolbar=self.get_bottom_toolbar if self.bottom_toolbar else None,
481482
complete_in_thread=True,
482483
complete_style=complete_style,
483484
complete_while_typing=False,
@@ -492,6 +493,7 @@ def _(event: Any) -> None: # pragma: no cover
492493
# where isatty() is True but there is no real console.
493494
self.session = PromptSession(
494495
auto_suggest=self.auto_suggest,
496+
bottom_toolbar=self.get_bottom_toolbar if self.bottom_toolbar else None,
495497
complete_in_thread=True,
496498
complete_style=complete_style,
497499
complete_while_typing=False,
@@ -3409,29 +3411,29 @@ def get_prompt() -> ANSI | str:
34093411
history_to_use.append_string(item)
34103412

34113413
temp_session1: PromptSession[str] = PromptSession(
3414+
complete_style=self.session.complete_style,
3415+
complete_while_typing=self.session.complete_while_typing,
34123416
history=history_to_use,
34133417
input=self.session.input,
3414-
output=self.session.output,
34153418
lexer=self.lexer,
3416-
complete_style=self.session.complete_style,
3417-
complete_while_typing=self.session.complete_while_typing,
3419+
output=self.session.output,
34183420
)
34193421

34203422
return temp_session1.prompt(
34213423
prompt_to_use,
3424+
bottom_toolbar=self.get_bottom_toolbar if self.bottom_toolbar else None,
34223425
completer=completer_to_use,
34233426
lexer=self.lexer,
34243427
pre_run=self.pre_prompt,
3425-
bottom_toolbar=self.get_bottom_toolbar if self.bottom_toolbar else None,
34263428
)
34273429

34283430
# history is None
34293431
return self.session.prompt(
34303432
prompt_to_use,
3433+
bottom_toolbar=self.get_bottom_toolbar if self.bottom_toolbar else None,
34313434
completer=completer_to_use,
34323435
lexer=self.lexer,
34333436
pre_run=self.pre_prompt,
3434-
bottom_toolbar=self.get_bottom_toolbar if self.bottom_toolbar else None,
34353437
)
34363438

34373439
# Otherwise read from self.stdin
@@ -3446,24 +3448,24 @@ def get_prompt() -> ANSI | str:
34463448
)
34473449
line = temp_session2.prompt(
34483450
prompt,
3449-
pre_run=self.pre_prompt,
34503451
bottom_toolbar=self.get_bottom_toolbar if self.bottom_toolbar else None,
3452+
pre_run=self.pre_prompt,
34513453
)
34523454
if len(line) == 0:
34533455
raise EOFError
34543456
return line.rstrip('\n')
34553457
else:
34563458
# not a tty, just read the line
34573459
temp_session3: PromptSession[str] = PromptSession(
3458-
input=self.session.input,
3459-
output=self.session.output,
3460-
lexer=self.lexer,
34613460
complete_style=self.session.complete_style,
34623461
complete_while_typing=self.session.complete_while_typing,
3462+
input=self.session.input,
3463+
lexer=self.lexer,
3464+
output=self.session.output,
34633465
)
34643466
line = temp_session3.prompt(
3465-
pre_run=self.pre_prompt,
34663467
bottom_toolbar=self.get_bottom_toolbar if self.bottom_toolbar else None,
3468+
pre_run=self.pre_prompt,
34673469
)
34683470
if len(line) == 0:
34693471
raise EOFError

0 commit comments

Comments
 (0)