we lose aliases in the help output but this does fix shell completion, which is more important.

fixes #3
This commit is contained in:
2026-02-07 05:20:37 +00:00
parent 34067ca61d
commit 9693d4f913
19 changed files with 180 additions and 141 deletions

View File

@@ -1,7 +1,5 @@
"""module defining a custom group class for handling command name aliases."""
import re
import typer
@@ -53,25 +51,3 @@ class RootTyperAliasGroup(typer.core.TyperGroup):
case 'vc':
cmd_name = 'virtualcam'
return super().get_command(ctx, cmd_name)
class SubTyperAliasGroup(typer.core.TyperGroup):
"""A custom group class to handle command name aliases for sub typers."""
_CMD_SPLIT_P = re.compile(r' ?[,|] ?')
def __init__(self, *args, **kwargs):
"""Initialize the AliasGroup."""
super().__init__(*args, **kwargs)
self.no_args_is_help = True
def get_command(self, ctx, cmd_name):
"""Get a command by name."""
cmd_name = self._group_cmd_name(cmd_name)
return super().get_command(ctx, cmd_name)
def _group_cmd_name(self, default_name):
for cmd in self.commands.values():
if cmd.name and default_name in self._CMD_SPLIT_P.split(cmd.name):
return cmd.name
return default_name