Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ prompt is displayed.
driven by the `DEFAULT_CATEGORY` class variable (see **Simplified command categorization** in
the Enhancements section below for details).
- Removed `Cmd.undoc_header` since all commands are now considered categorized.
- Renamed `Cmd.cmd_func()` to `Cmd.get_command_func()`.
- Enhancements
- New `cmd2.Cmd` parameters
- **auto_suggest**: (boolean) if `True`, provide fish shell style auto-suggestions. These
Expand Down Expand Up @@ -107,6 +108,10 @@ prompt is displayed.
- Individual commands can still be manually moved using the `with_category()` decorator.
- For more details and examples, see the [Help](docs/features/help.md) documentation and the
`examples/default_categories.py` file.
- `CommandSet` is now a generic class, which allows developers to parameterize it with their
specific `cmd2.Cmd` subclass (e.g.,`class MyCommandSet(CommandSet[MyApp]):`). This provides
full type hints and IDE autocompletion for `self._cmd` without needing to override and cast
the property.

## 3.5.0 (April 13, 2026)

Expand Down
16 changes: 8 additions & 8 deletions cmd2/argparse_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
from .exceptions import CompletionError
from .rich_utils import Cmd2SimpleTable
from .types import (
ChoicesProviderUnbound,
CmdOrSet,
CompleterUnbound,
CmdOrSetT,
Comment thread
tleonhardt marked this conversation as resolved.
UnboundChoicesProvider,
UnboundCompleter,
)

if TYPE_CHECKING: # pragma: no cover
Expand Down Expand Up @@ -214,7 +214,7 @@ def complete(
endidx: int,
tokens: Sequence[str],
*,
cmd_set: CommandSet | None = None,
cmd_set: CommandSet[Any] | None = None,
) -> Completions:
"""Complete text using argparse metadata.

Expand Down Expand Up @@ -469,7 +469,7 @@ def _handle_last_token(
consumed_arg_values: dict[str, list[str]],
used_flags: set[str],
skip_remaining_flags: bool,
cmd_set: CommandSet | None,
cmd_set: CommandSet[Any] | None,
) -> Completions:
"""Perform final completion step handling positionals and flags."""
# Check if we are completing a flag name. This check ignores strings with a length of one, like '-'.
Expand Down Expand Up @@ -734,11 +734,11 @@ def _choices_to_items(self, arg_state: _ArgumentState) -> list[CompletionItem]:

def _prepare_callable_params(
self,
to_call: ChoicesProviderUnbound[CmdOrSet] | CompleterUnbound[CmdOrSet],
to_call: UnboundChoicesProvider[CmdOrSetT] | UnboundCompleter[CmdOrSetT],
arg_state: _ArgumentState,
text: str,
consumed_arg_values: dict[str, list[str]],
cmd_set: CommandSet | None,
cmd_set: CommandSet[Any] | None,
) -> tuple[list[Any], dict[str, Any]]:
"""Resolve the instance and arguments required to call a choices/completer function."""
args: list[Any] = []
Expand Down Expand Up @@ -769,7 +769,7 @@ def _complete_arg(
arg_state: _ArgumentState,
consumed_arg_values: dict[str, list[str]],
*,
cmd_set: CommandSet | None = None,
cmd_set: CommandSet[Any] | None = None,
) -> Completions:
"""Completion routine for an argparse argument.

Expand Down
10 changes: 5 additions & 5 deletions cmd2/argparse_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ def get_choices(self) -> Choices:
from .rich_utils import Cmd2RichArgparseConsole
from .styles import Cmd2Style
from .types import (
ChoicesProviderUnbound,
CmdOrSet,
CompleterUnbound,
CmdOrSetT,
UnboundChoicesProvider,
UnboundCompleter,
)

if TYPE_CHECKING: # pragma: no cover
Expand Down Expand Up @@ -388,8 +388,8 @@ def _ActionsContainer_add_argument( # noqa: N802
self: argparse._ActionsContainer,
*args: Any,
nargs: int | str | tuple[int] | tuple[int, int] | tuple[int, float] | None = None,
choices_provider: ChoicesProviderUnbound[CmdOrSet] | None = None,
completer: CompleterUnbound[CmdOrSet] | None = None,
choices_provider: UnboundChoicesProvider[CmdOrSetT] | None = None,
completer: UnboundCompleter[CmdOrSetT] | None = None,
suppress_tab_hint: bool = False,
table_columns: Sequence[str | Column] | None = None,
**kwargs: Any,
Expand Down
Loading
Loading