Compare commits

...

4 Commits

Author SHA1 Message Date
3dbff1cc4d add 0.15.0 to CHANGELOG
minor bump
2025-06-02 17:32:52 +01:00
75fdbf5ad8 raise typer.Exit() to signify we return early with exit code 0 2025-06-02 17:32:34 +01:00
ec444d9cdd add version_callback
rename version command to obs-version

upd version unit test
2025-06-02 17:31:44 +01:00
370c82f393 update root typer section:
- add --version/-v option
- upd version command
2025-06-02 17:22:15 +01:00
10 changed files with 54 additions and 11 deletions

View File

@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
# [0.15.0] - 2025-06-02
### Added
- root typer now accepts --version/-v option, it returns the CLI version. See [Root Typer](https://github.com/onyx-and-iris/obsws-cli?tab=readme-ov-file#root-typer)
### Changed
- version command renamed to obs-version
# [0.14.2] - 2025-05-29
### Changed

View File

@ -64,10 +64,16 @@ Flags can be used to override environment variables.
## Root Typer
- version: Get the OBS Client and WebSocket versions.
- --version/-v: Get the obsws-cli version:
```console
obsws-cli version
obsws-cli --version
```
- obs-version: Get the OBS Client and WebSocket versions.
```console
obsws-cli obs-version
```
## Sub Typers

View File

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

View File

@ -6,6 +6,8 @@ import obsws_python as obsws
import typer
from rich.console import Console
from obsws_cli.__about__ import __version__ as obsws_cli_version
from . import (
filter,
group,
@ -48,6 +50,13 @@ out_console = Console()
err_console = Console(stderr=True)
def version_callback(value: bool):
"""Show the version of the CLI."""
if value:
typer.echo(f'obsws_cli version: {obsws_cli_version}')
raise typer.Exit()
@app.callback()
def main(
ctx: typer.Context,
@ -68,13 +77,24 @@ def main(
int,
typer.Option(envvar='OBS_TIMEOUT', help='WebSocket timeout', show_default=5),
] = settings.get('TIMEOUT'),
version: Annotated[
bool,
typer.Option(
'--version',
'-v',
is_eager=True,
help='Show the CLI version and exit',
show_default=False,
callback=version_callback,
),
] = False,
):
"""obsws_cli is a command line interface for the OBS WebSocket API."""
ctx.obj = ctx.with_resource(obsws.ReqClient(**ctx.params))
@app.command()
def version(ctx: typer.Context):
def obs_version(ctx: typer.Context):
"""Get the OBS Client and WebSocket versions."""
resp = ctx.obj.get_version()
out_console.print(

View File

@ -32,7 +32,7 @@ def list(ctx: typer.Context, source_name: str):
if not resp.filters:
out_console.print(f'No filters found for source {source_name}')
return
raise typer.Exit()
table = Table(title=f'Filters for Source: {source_name}', padding=(0, 2))

View File

@ -42,7 +42,7 @@ def list(
if not groups:
out_console.print(f"No groups found in scene '{scene_name}'.")
return
raise typer.Exit()
table = Table(title=f'Groups in Scene: {scene_name}', padding=(0, 2))

View File

@ -49,7 +49,7 @@ def list(
if not inputs:
out_console.print('No inputs found.')
return
raise typer.Exit()
table = Table(title='Inputs', padding=(0, 2))
for column in ('Input Name', 'Kind'):

View File

@ -52,7 +52,7 @@ def list(
if not items:
out_console.print(f"No items found in scene '{scene_name}'.")
return
raise typer.Exit()
table = Table(title=f'Items in Scene: {scene_name}', padding=(0, 2))
for column in ('Item ID', 'Item Name', 'In Group', 'Enabled'):

View File

@ -22,7 +22,7 @@ classifiers = [
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = [
"typer>=0.15.2",
"typer>=0.16.0",
"obsws-python>=1.7.2",
"pydantic-settings>=2.9.1",
]

View File

@ -8,8 +8,15 @@ runner = CliRunner(mix_stderr=False)
def test_version():
"""Test the version command."""
result = runner.invoke(app, ['version'])
"""Test the version option."""
result = runner.invoke(app, ['--version'])
assert result.exit_code == 0
assert 'obsws_cli version:' in result.stdout
def test_obs_version():
"""Test the obs-version command."""
result = runner.invoke(app, ['obs-version'])
assert result.exit_code == 0
assert 'OBS Client version' in result.stdout
assert 'WebSocket version' in result.stdout