use tuples as records to build the tables

add --fempg and --vlc options to filter list

add Muted column to list table
This commit is contained in:
onyx-and-iris 2025-06-06 23:27:16 +01:00
parent cd7614bfd6
commit 1ff610410a

View File

@ -25,6 +25,8 @@ def list_(
input: Annotated[bool, typer.Option(help='Filter by input type.')] = False, input: Annotated[bool, typer.Option(help='Filter by input type.')] = False,
output: Annotated[bool, typer.Option(help='Filter by output type.')] = False, output: Annotated[bool, typer.Option(help='Filter by output type.')] = False,
colour: Annotated[bool, typer.Option(help='Filter by colour source type.')] = False, colour: Annotated[bool, typer.Option(help='Filter by colour source type.')] = False,
ffmpeg: Annotated[bool, typer.Option(help='Filter by ffmpeg source type.')] = False,
vlc: Annotated[bool, typer.Option(help='Filter by VLC source type.')] = False,
): ):
"""List all inputs.""" """List all inputs."""
resp = ctx.obj.get_input_list() resp = ctx.obj.get_input_list()
@ -36,8 +38,12 @@ def list_(
kinds.append('output') kinds.append('output')
if colour: if colour:
kinds.append('color') kinds.append('color')
if not any([input, output, colour]): if ffmpeg:
kinds = ['input', 'output', 'color'] kinds.append('ffmpeg')
if vlc:
kinds.append('vlc')
if not any([input, output, colour, ffmpeg, vlc]):
kinds = ['input', 'output', 'color', 'ffmpeg', 'vlc']
inputs = [ inputs = [
(input_.get('inputName'), input_.get('inputKind')) (input_.get('inputName'), input_.get('inputKind'))
@ -52,15 +58,27 @@ def list_(
raise typer.Exit() raise typer.Exit()
table = Table(title='Inputs', padding=(0, 2)) table = Table(title='Inputs', padding=(0, 2))
for column in ('Input Name', 'Kind'): columns = [
table.add_column( ('Input Name', 'left', 'cyan'),
column, justify='left' if column == 'Input Name' else 'center', style='cyan' ('Kind', 'center', 'cyan'),
) ('Muted', 'center', None),
]
for column, justify, style in columns:
table.add_column(column, justify=justify, style=style)
for input_name, input_kind in inputs: for input_name, input_kind in inputs:
input_mark = ''
if any(
kind in input_kind
for kind in ['input_capture', 'output_capture', 'ffmpeg', 'vlc']
):
input_muted = ctx.obj.get_input_mute(name=input_name).input_muted
input_mark = ':white_heavy_check_mark:' if input_muted else ':x:'
table.add_row( table.add_row(
input_name, input_name,
util.snakecase_to_titlecase(input_kind), util.snakecase_to_titlecase(input_kind),
input_mark,
) )
out_console.print(table) out_console.print(table)