enable no_args_is_help for all typers subclassing AliasGroup

This includes the root typer

patch bump
This commit is contained in:
onyx-and-iris 2025-04-21 20:19:21 +01:00
parent d945a6fa40
commit 023fdf708b
4 changed files with 9 additions and 3 deletions

View File

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2025-present onyx-and-iris <code@onyxandiris.online>
#
# SPDX-License-Identifier: MIT
__version__ = "0.6.6"
__version__ = "0.6.7"

View File

@ -10,6 +10,11 @@ class AliasGroup(typer.core.TyperGroup):
_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)

View File

@ -9,6 +9,7 @@ from pydantic import ConfigDict
from pydantic_settings import BaseSettings
from . import group, input, record, scene, scenecollection, sceneitem, stream
from .alias import AliasGroup
class Settings(BaseSettings):
@ -29,7 +30,7 @@ class Settings(BaseSettings):
TIMEOUT: int = 5 # Timeout for requests in seconds
app = typer.Typer()
app = typer.Typer(cls=AliasGroup)
app.add_typer(scene.app, name='scene')
app.add_typer(sceneitem.app, name='scene-item')
app.add_typer(group.app, name='group')

View File

@ -39,7 +39,7 @@ obsws-cli = "obsws_cli:app"
path = "obsws_cli/__about__.py"
[tool.hatch.envs.default.scripts]
cli = "obsws-cli {args:obsws_cli}"
cli = "obsws-cli {args:}"
test = "pytest {args:obsws_cli tests}"
[tool.hatch.envs.hatch-test]