mirror of
https://github.com/onyx-and-iris/obsws-cli.git
synced 2025-06-27 05:50:32 +01:00
add RootTyperAliasGroup
improve the output of projector open if the monitor index is invalid (suggests prj ls-m) fix highlight for sceneitem commands in _validate_sources() patch bump
This commit is contained in:
parent
23282a60d1
commit
7abbccae99
@ -1,4 +1,4 @@
|
||||
# SPDX-FileCopyrightText: 2025-present onyx-and-iris <code@onyxandiris.online>
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
__version__ = "0.17.5"
|
||||
__version__ = "0.17.6"
|
||||
|
@ -5,8 +5,52 @@ import re
|
||||
import typer
|
||||
|
||||
|
||||
class AliasGroup(typer.core.TyperGroup):
|
||||
"""A custom group class to handle command name aliases."""
|
||||
class RootTyperAliasGroup(typer.core.TyperGroup):
|
||||
"""A custom group class to handle command name aliases for the root typer."""
|
||||
|
||||
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."""
|
||||
match cmd_name:
|
||||
case 'f':
|
||||
cmd_name = 'filter'
|
||||
case 'g':
|
||||
cmd_name = 'group'
|
||||
case 'hk':
|
||||
cmd_name = 'hotkey'
|
||||
case 'i':
|
||||
cmd_name = 'input'
|
||||
case 'prf':
|
||||
cmd_name = 'profile'
|
||||
case 'prj':
|
||||
cmd_name = 'projector'
|
||||
case 'rc':
|
||||
cmd_name = 'record'
|
||||
case 'rb':
|
||||
cmd_name = 'replaybuffer'
|
||||
case 'sc':
|
||||
cmd_name = 'scene'
|
||||
case 'scc':
|
||||
cmd_name = 'scenecollection'
|
||||
case 'si':
|
||||
cmd_name = 'sceneitem'
|
||||
case 'ss':
|
||||
cmd_name = 'screenshot'
|
||||
case 'st':
|
||||
cmd_name = 'stream'
|
||||
case 'sm':
|
||||
cmd_name = 'studiomode'
|
||||
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' ?[,|] ?')
|
||||
|
||||
@ -22,7 +66,6 @@ class AliasGroup(typer.core.TyperGroup):
|
||||
|
||||
def _group_cmd_name(self, default_name):
|
||||
for cmd in self.commands.values():
|
||||
name = cmd.name
|
||||
if name and default_name in self._CMD_SPLIT_P.split(name):
|
||||
return name
|
||||
if cmd.name and default_name in self._CMD_SPLIT_P.split(cmd.name):
|
||||
return cmd.name
|
||||
return default_name
|
||||
|
@ -10,9 +10,9 @@ import typer
|
||||
from obsws_cli.__about__ import __version__ as obsws_cli_version
|
||||
|
||||
from . import console, settings
|
||||
from .alias import AliasGroup
|
||||
from .alias import RootTyperAliasGroup
|
||||
|
||||
app = typer.Typer(cls=AliasGroup)
|
||||
app = typer.Typer(cls=RootTyperAliasGroup)
|
||||
for sub_typer in (
|
||||
'filter',
|
||||
'group',
|
||||
|
@ -7,9 +7,9 @@ import typer
|
||||
from rich.table import Table
|
||||
|
||||
from . import console, util
|
||||
from .alias import AliasGroup
|
||||
from .alias import SubTyperAliasGroup
|
||||
|
||||
app = typer.Typer(cls=AliasGroup)
|
||||
app = typer.Typer(cls=SubTyperAliasGroup)
|
||||
|
||||
|
||||
@app.callback()
|
||||
|
@ -6,10 +6,10 @@ import typer
|
||||
from rich.table import Table
|
||||
|
||||
from . import console, util, validate
|
||||
from .alias import AliasGroup
|
||||
from .alias import SubTyperAliasGroup
|
||||
from .protocols import DataclassProtocol
|
||||
|
||||
app = typer.Typer(cls=AliasGroup)
|
||||
app = typer.Typer(cls=SubTyperAliasGroup)
|
||||
|
||||
|
||||
@app.callback()
|
||||
|
@ -6,9 +6,9 @@ import typer
|
||||
from rich.table import Table
|
||||
|
||||
from . import console
|
||||
from .alias import AliasGroup
|
||||
from .alias import SubTyperAliasGroup
|
||||
|
||||
app = typer.Typer(cls=AliasGroup)
|
||||
app = typer.Typer(cls=SubTyperAliasGroup)
|
||||
|
||||
|
||||
@app.callback()
|
||||
|
@ -7,9 +7,9 @@ import typer
|
||||
from rich.table import Table
|
||||
|
||||
from . import console, util, validate
|
||||
from .alias import AliasGroup
|
||||
from .alias import SubTyperAliasGroup
|
||||
|
||||
app = typer.Typer(cls=AliasGroup)
|
||||
app = typer.Typer(cls=SubTyperAliasGroup)
|
||||
|
||||
|
||||
@app.callback()
|
||||
|
@ -6,9 +6,9 @@ import typer
|
||||
from rich.table import Table
|
||||
|
||||
from . import console, util, validate
|
||||
from .alias import AliasGroup
|
||||
from .alias import SubTyperAliasGroup
|
||||
|
||||
app = typer.Typer(cls=AliasGroup)
|
||||
app = typer.Typer(cls=SubTyperAliasGroup)
|
||||
|
||||
|
||||
@app.callback()
|
||||
|
@ -6,9 +6,9 @@ import typer
|
||||
from rich.table import Table
|
||||
|
||||
from . import console
|
||||
from .alias import AliasGroup
|
||||
from .alias import SubTyperAliasGroup
|
||||
|
||||
app = typer.Typer(cls=AliasGroup)
|
||||
app = typer.Typer(cls=SubTyperAliasGroup)
|
||||
|
||||
|
||||
@app.callback()
|
||||
@ -74,6 +74,7 @@ def open(
|
||||
break
|
||||
else:
|
||||
console.err.print(
|
||||
f'Monitor with index [yellow]{monitor_index}[/yellow] not found.'
|
||||
f'Monitor with index [yellow]{monitor_index}[/yellow] not found. '
|
||||
f'Use [yellow]obsws-cli projector ls-m[/yellow] to see available monitors.'
|
||||
)
|
||||
raise typer.Exit(code=1)
|
||||
|
@ -6,9 +6,9 @@ from typing import Annotated, Optional
|
||||
import typer
|
||||
|
||||
from . import console
|
||||
from .alias import AliasGroup
|
||||
from .alias import SubTyperAliasGroup
|
||||
|
||||
app = typer.Typer(cls=AliasGroup)
|
||||
app = typer.Typer(cls=SubTyperAliasGroup)
|
||||
|
||||
|
||||
@app.callback()
|
||||
|
@ -3,9 +3,9 @@
|
||||
import typer
|
||||
|
||||
from . import console
|
||||
from .alias import AliasGroup
|
||||
from .alias import SubTyperAliasGroup
|
||||
|
||||
app = typer.Typer(cls=AliasGroup)
|
||||
app = typer.Typer(cls=SubTyperAliasGroup)
|
||||
|
||||
|
||||
@app.callback()
|
||||
|
@ -6,9 +6,9 @@ import typer
|
||||
from rich.table import Table
|
||||
|
||||
from . import console, util, validate
|
||||
from .alias import AliasGroup
|
||||
from .alias import SubTyperAliasGroup
|
||||
|
||||
app = typer.Typer(cls=AliasGroup)
|
||||
app = typer.Typer(cls=SubTyperAliasGroup)
|
||||
|
||||
|
||||
@app.callback()
|
||||
|
@ -6,9 +6,9 @@ import typer
|
||||
from rich.table import Table
|
||||
|
||||
from . import console, validate
|
||||
from .alias import AliasGroup
|
||||
from .alias import SubTyperAliasGroup
|
||||
|
||||
app = typer.Typer(cls=AliasGroup)
|
||||
app = typer.Typer(cls=SubTyperAliasGroup)
|
||||
|
||||
|
||||
@app.callback()
|
||||
|
@ -6,9 +6,9 @@ import typer
|
||||
from rich.table import Table
|
||||
|
||||
from . import console, util, validate
|
||||
from .alias import AliasGroup
|
||||
from .alias import SubTyperAliasGroup
|
||||
|
||||
app = typer.Typer(cls=AliasGroup)
|
||||
app = typer.Typer(cls=SubTyperAliasGroup)
|
||||
|
||||
|
||||
@app.callback()
|
||||
@ -154,7 +154,7 @@ def _validate_sources(
|
||||
console.err.print(
|
||||
f'Item [yellow]{item_name}[/yellow] not found in scene [yellow]{scene_name}[/yellow]. Is the item in a group? '
|
||||
f'If so use the [yellow]--group[/yellow] option to specify the parent group.\n'
|
||||
'Use `obsws-cli sceneitem list` for a list of items in the scene.'
|
||||
'Use [yellow]obsws-cli sceneitem ls[/yellow] for a list of items in the scene.'
|
||||
)
|
||||
return False
|
||||
|
||||
|
@ -7,9 +7,9 @@ import obsws_python as obsws
|
||||
import typer
|
||||
|
||||
from . import console
|
||||
from .alias import AliasGroup
|
||||
from .alias import SubTyperAliasGroup
|
||||
|
||||
app = typer.Typer(cls=AliasGroup)
|
||||
app = typer.Typer(cls=SubTyperAliasGroup)
|
||||
|
||||
|
||||
@app.callback()
|
||||
|
@ -3,9 +3,9 @@
|
||||
import typer
|
||||
|
||||
from . import console
|
||||
from .alias import AliasGroup
|
||||
from .alias import SubTyperAliasGroup
|
||||
|
||||
app = typer.Typer(cls=AliasGroup)
|
||||
app = typer.Typer(cls=SubTyperAliasGroup)
|
||||
|
||||
|
||||
@app.callback()
|
||||
|
@ -3,9 +3,9 @@
|
||||
import typer
|
||||
|
||||
from . import console
|
||||
from .alias import AliasGroup
|
||||
from .alias import SubTyperAliasGroup
|
||||
|
||||
app = typer.Typer(cls=AliasGroup)
|
||||
app = typer.Typer(cls=SubTyperAliasGroup)
|
||||
|
||||
|
||||
@app.callback()
|
||||
|
@ -3,9 +3,9 @@
|
||||
import typer
|
||||
|
||||
from . import console
|
||||
from .alias import AliasGroup
|
||||
from .alias import SubTyperAliasGroup
|
||||
|
||||
app = typer.Typer(cls=AliasGroup)
|
||||
app = typer.Typer(cls=SubTyperAliasGroup)
|
||||
|
||||
|
||||
@app.callback()
|
||||
|
Loading…
x
Reference in New Issue
Block a user