Skip to content

Commit 43d5ee1

Browse files
authored
Merge branch 'main' into pt-colors
2 parents 0b5e443 + a3890a7 commit 43d5ee1

12 files changed

Lines changed: 14 additions & 61 deletions

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ prompt is displayed.
9999
- Renamed `Cmd._command_parsers` to `Cmd.command_parsers`.
100100
- Removed `RichPrintKwargs` `TypedDict` in favor of using `Mapping[str, Any]`, allowing for
101101
greater flexibility in passing keyword arguments to `console.print()` calls.
102+
- Removed `always_show_hint` settable as it provided a poor user experience with
103+
`prompt-toolkit`
102104
- Enhancements
103105
- New `cmd2.Cmd` parameters
104106
- **auto_suggest**: (boolean) if `True`, provide fish shell style auto-suggestions. These

cmd2/argparse_completer.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -491,13 +491,6 @@ def _handle_last_token(
491491

492492
# If we have results, then return them
493493
if completions:
494-
if not completions.hint:
495-
# Add a hint even though there are results in case Cmd.always_show_hint is True.
496-
completions = dataclasses.replace(
497-
completions,
498-
hint=_build_hint(self._parser, flag_arg_state.action),
499-
)
500-
501494
return completions
502495

503496
# Otherwise, print a hint if the flag isn't finished or text isn't possibly the start of a flag
@@ -519,12 +512,6 @@ def _handle_last_token(
519512

520513
# If we have results, then return them
521514
if completions:
522-
if not completions.hint:
523-
# Add a hint even though there are results in case Cmd.always_show_hint is True.
524-
completions = dataclasses.replace(
525-
completions,
526-
hint=_build_hint(self._parser, pos_arg_state.action),
527-
)
528515
return completions
529516

530517
# Otherwise, print a hint if text isn't possibly the start of a flag

cmd2/cmd2.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@ def __init__(
398398
instantiate and register all commands. If False, CommandSets
399399
must be manually installed with `register_command_set`.
400400
:param auto_suggest: If True, cmd2 will provide fish shell style auto-suggestions
401-
based on history. If False, these will not be provided.
401+
based on history. User can press right-arrow key to accept the
402+
provided suggestion.
402403
:param bottom_toolbar: if ``True``, then a bottom toolbar will be displayed.
403404
:param command_sets: Provide CommandSet instances to load during cmd2 initialization.
404405
This allows CommandSets with custom constructor parameters to be
@@ -467,7 +468,6 @@ def __init__(
467468
self.interactive_pipe = False
468469

469470
# Attributes which ARE dynamically settable via the set command at runtime
470-
self.always_show_hint = False
471471
self.debug = False
472472
self.echo = False
473473
self.editor = self.DEFAULT_EDITOR
@@ -1356,10 +1356,6 @@ def allow_style_type(value: str) -> ru.AllowStyle:
13561356
choices_provider=get_allow_style_choices,
13571357
)
13581358
)
1359-
1360-
self.add_settable(
1361-
Settable("always_show_hint", bool, "Display completion hint even when completion suggestions print", self)
1362-
)
13631359
self.add_settable(Settable("debug", bool, "Show full traceback on exception", self))
13641360
self.add_settable(Settable("echo", bool, "Echo command issued into output", self))
13651361
self.add_settable(Settable("editor", str, "Program used by 'edit'", self))

cmd2/pt_utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,10 @@ def get_completions(self, document: Document, _complete_event: object) -> Iterab
124124
console.print(completions.table, end="", soft_wrap=False)
125125
print_formatted_text(pt_filter_style("\n" + capture.get()))
126126

127-
# Print hint if present and settings say we should
128-
if completions.hint and (self.cmd_app.always_show_hint or not completions):
129-
print_formatted_text(pt_filter_style(completions.hint))
130-
131127
if not completions:
128+
# # Print hint if present
129+
if completions.hint:
130+
print_formatted_text(pt_filter_style(completions.hint))
132131
return
133132

134133
# The length of the user's input minus any shortcut.

docs/features/builtin_commands.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ application:
8080
Name Value Description
8181
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
8282
allow_style Terminal Allow ANSI text style sequences in output (valid values: Always, Never, Terminal)
83-
always_show_hint False Display completion hint even when completion suggestions print
8483
debug False Show full traceback on exception
8584
echo False Echo command issued into output
8685
editor vim Program used by 'edit'

docs/features/initialization.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ The `cmd2.Cmd` class provides a large number of public instance attributes which
3333

3434
Here are instance attributes of `cmd2.Cmd` which developers might wish to override:
3535

36-
- **always_show_hint**: if `True`, display tab completion hint even when completion suggestions print (Default: `False`)
3736
- **bottom_toolbar**: if `True`, then a bottom toolbar will be displayed (Default: `False`)
3837
- **broken_pipe_warning**: if non-empty, this string will be displayed if a broken pipe error occurs
3938
- **continuation_prompt**: used for multiline commands on 2nd+ line of input

docs/features/settings.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ This setting can be one of three values:
3737
stripped.
3838
- `Always` - ANSI escape sequences are always passed through to the output
3939

40-
### always_show_hint
41-
42-
If `True`, display tab completion hint even when completion suggestions print. The default value of
43-
this setting is `False`.
44-
4540
### debug
4641

4742
The default value of this setting is `False`, which causes the `cmd2.Cmd.pexcept` method to only

tests/scripts/postcmds.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
set always_show_hint False
1+
set allow_style Terminal

tests/scripts/precmds.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
set always_show_hint True
1+
set allow_style Always

tests/test_cmd2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,11 +488,11 @@ def test_run_script_nested_run_scripts(base_app, request) -> None:
488488
expected = f"""
489489
{initial_run}
490490
_relative_run_script precmds.txt
491-
set always_show_hint True
491+
set allow_style Always
492492
help
493493
shortcuts
494494
_relative_run_script postcmds.txt
495-
set always_show_hint False"""
495+
set allow_style Terminal"""
496496
out, _err = run_cmd(base_app, "history -s")
497497
assert out == normalize(expected)
498498

@@ -505,11 +505,11 @@ def test_runcmds_plus_hooks(base_app, request) -> None:
505505
base_app.runcmds_plus_hooks(["run_script " + prefilepath, "help", "shortcuts", "run_script " + postfilepath])
506506
expected = f"""
507507
run_script {prefilepath}
508-
set always_show_hint True
508+
set allow_style Always
509509
help
510510
shortcuts
511511
run_script {postfilepath}
512-
set always_show_hint False"""
512+
set allow_style Terminal"""
513513

514514
out, _err = run_cmd(base_app, "history -s")
515515
assert out == normalize(expected)

0 commit comments

Comments
 (0)