mirror of
https://github.com/onyx-and-iris/obsws-cli.git
synced 2025-06-07 20:20:32 +01:00
error messages now have style `bold red` error highlights are now yellow normal highlights are now green patch bump
67 lines
1.7 KiB
Python
67 lines
1.7 KiB
Python
"""module containing commands for manipulating the replay buffer in OBS."""
|
|
|
|
import typer
|
|
from rich.console import Console
|
|
|
|
from .alias import AliasGroup
|
|
|
|
app = typer.Typer(cls=AliasGroup)
|
|
out_console = Console()
|
|
err_console = Console(stderr=True, style='bold red')
|
|
|
|
|
|
@app.callback()
|
|
def main():
|
|
"""Control profiles in OBS."""
|
|
|
|
|
|
@app.command('start | s')
|
|
def start(ctx: typer.Context):
|
|
"""Start the replay buffer."""
|
|
resp = ctx.obj.get_replay_buffer_status()
|
|
if resp.output_active:
|
|
err_console.print('Replay buffer is already active.')
|
|
raise typer.Exit(1)
|
|
|
|
ctx.obj.start_replay_buffer()
|
|
out_console.print('Replay buffer started.')
|
|
|
|
|
|
@app.command('stop | st')
|
|
def stop(ctx: typer.Context):
|
|
"""Stop the replay buffer."""
|
|
resp = ctx.obj.get_replay_buffer_status()
|
|
if not resp.output_active:
|
|
err_console.print('Replay buffer is not active.')
|
|
raise typer.Exit(1)
|
|
|
|
ctx.obj.stop_replay_buffer()
|
|
out_console.print('Replay buffer stopped.')
|
|
|
|
|
|
@app.command('toggle | tg')
|
|
def toggle(ctx: typer.Context):
|
|
"""Toggle the replay buffer."""
|
|
resp = ctx.obj.toggle_replay_buffer()
|
|
if resp.output_active:
|
|
out_console.print('Replay buffer is active.')
|
|
else:
|
|
out_console.print('Replay buffer is not active.')
|
|
|
|
|
|
@app.command('status | ss')
|
|
def status(ctx: typer.Context):
|
|
"""Get the status of the replay buffer."""
|
|
resp = ctx.obj.get_replay_buffer_status()
|
|
if resp.output_active:
|
|
out_console.print('Replay buffer is active.')
|
|
else:
|
|
out_console.print('Replay buffer is not active.')
|
|
|
|
|
|
@app.command('save | sv')
|
|
def save(ctx: typer.Context):
|
|
"""Save the replay buffer."""
|
|
ctx.obj.save_replay_buffer()
|
|
out_console.print('Replay buffer saved.')
|