mirror of
https://github.com/onyx-and-iris/obsws-cli.git
synced 2025-08-05 19:31:45 +00:00
convert hotkey commands
This commit is contained in:
parent
ae8ff20cf4
commit
132b283347
@ -24,6 +24,7 @@ app = App(
|
|||||||
app.meta.group_parameters = Group('Options', sort_key=0)
|
app.meta.group_parameters = Group('Options', sort_key=0)
|
||||||
for sub_app in (
|
for sub_app in (
|
||||||
'group',
|
'group',
|
||||||
|
'hotkey',
|
||||||
'filter',
|
'filter',
|
||||||
'scene',
|
'scene',
|
||||||
):
|
):
|
||||||
|
@ -2,37 +2,33 @@
|
|||||||
|
|
||||||
from typing import Annotated
|
from typing import Annotated
|
||||||
|
|
||||||
import typer
|
from cyclopts import App, Argument, Parameter
|
||||||
from rich.table import Table
|
from rich.table import Table
|
||||||
from rich.text import Text
|
from rich.text import Text
|
||||||
|
|
||||||
from . import console
|
from . import console
|
||||||
from .alias import SubTyperAliasGroup
|
from .context import Context
|
||||||
|
|
||||||
app = typer.Typer(cls=SubTyperAliasGroup)
|
app = App(name='hotkey', help='Commands for managing hotkeys in OBS')
|
||||||
|
|
||||||
|
|
||||||
@app.callback()
|
@app.command(name=['list', 'ls'])
|
||||||
def main():
|
|
||||||
"""Control hotkeys in OBS."""
|
|
||||||
|
|
||||||
|
|
||||||
@app.command('list | ls')
|
|
||||||
def list_(
|
def list_(
|
||||||
ctx: typer.Context,
|
*,
|
||||||
|
ctx: Annotated[Context, Parameter(parse=False)],
|
||||||
):
|
):
|
||||||
"""List all hotkeys."""
|
"""List all hotkeys."""
|
||||||
resp = ctx.obj['obsws'].get_hotkey_list()
|
resp = ctx.client.get_hotkey_list()
|
||||||
|
|
||||||
table = Table(
|
table = Table(
|
||||||
title='Hotkeys',
|
title='Hotkeys',
|
||||||
padding=(0, 2),
|
padding=(0, 2),
|
||||||
border_style=ctx.obj['style'].border,
|
border_style=ctx.style.border,
|
||||||
)
|
)
|
||||||
table.add_column(
|
table.add_column(
|
||||||
Text('Hotkey Name', justify='center'),
|
Text('Hotkey Name', justify='center'),
|
||||||
justify='left',
|
justify='left',
|
||||||
style=ctx.obj['style'].column,
|
style=ctx.style.column,
|
||||||
)
|
)
|
||||||
|
|
||||||
for i, hotkey in enumerate(resp.hotkeys):
|
for i, hotkey in enumerate(resp.hotkeys):
|
||||||
@ -41,40 +37,40 @@ def list_(
|
|||||||
console.out.print(table)
|
console.out.print(table)
|
||||||
|
|
||||||
|
|
||||||
@app.command('trigger | tr')
|
@app.command(name=['trigger', 'tr'])
|
||||||
def trigger(
|
def trigger(
|
||||||
ctx: typer.Context,
|
hotkey: Annotated[str, Argument(hint='The hotkey to trigger')],
|
||||||
hotkey: Annotated[
|
/,
|
||||||
str, typer.Argument(..., show_default=False, help='The hotkey to trigger')
|
*,
|
||||||
],
|
ctx: Annotated[Context, Parameter(parse=False)],
|
||||||
):
|
):
|
||||||
"""Trigger a hotkey by name."""
|
"""Trigger a hotkey by name."""
|
||||||
ctx.obj['obsws'].trigger_hotkey_by_name(hotkey)
|
ctx.client.trigger_hotkey_by_name(hotkey)
|
||||||
|
|
||||||
|
|
||||||
@app.command('trigger-sequence | trs')
|
@app.command(name=['trigger-sequence', 'trs'])
|
||||||
def trigger_sequence(
|
def trigger_sequence(
|
||||||
ctx: typer.Context,
|
|
||||||
key_id: Annotated[
|
key_id: Annotated[
|
||||||
str,
|
str,
|
||||||
typer.Argument(
|
Argument(
|
||||||
...,
|
hint='The OBS key ID to trigger, see https://github.com/onyx-and-iris/obsws-cli?tab=readme-ov-file#hotkey for more info',
|
||||||
show_default=False,
|
|
||||||
help='The OBS key ID to trigger, see https://github.com/onyx-and-iris/obsws-cli?tab=readme-ov-file#hotkey for more info',
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
/,
|
||||||
shift: Annotated[
|
shift: Annotated[
|
||||||
bool, typer.Option(..., help='Press shift when triggering the hotkey')
|
bool, Parameter(help='Press shift when triggering the hotkey')
|
||||||
] = False,
|
] = False,
|
||||||
ctrl: Annotated[
|
ctrl: Annotated[
|
||||||
bool, typer.Option(..., help='Press control when triggering the hotkey')
|
bool, Parameter(help='Press control when triggering the hotkey')
|
||||||
] = False,
|
] = False,
|
||||||
alt: Annotated[
|
alt: Annotated[
|
||||||
bool, typer.Option(..., help='Press alt when triggering the hotkey')
|
bool, Parameter(help='Press alt when triggering the hotkey')
|
||||||
] = False,
|
] = False,
|
||||||
cmd: Annotated[
|
cmd: Annotated[
|
||||||
bool, typer.Option(..., help='Press cmd when triggering the hotkey')
|
bool, Parameter(help='Press cmd when triggering the hotkey')
|
||||||
] = False,
|
] = False,
|
||||||
|
*,
|
||||||
|
ctx: Annotated[Context, Parameter(parse=False)],
|
||||||
):
|
):
|
||||||
"""Trigger a hotkey by sequence."""
|
"""Trigger a hotkey by sequence."""
|
||||||
ctx.obj['obsws'].trigger_hotkey_by_key_sequence(key_id, shift, ctrl, alt, cmd)
|
ctx.client.trigger_hotkey_by_key_sequence(key_id, shift, ctrl, alt, cmd)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user