add --version/-v flag

This commit is contained in:
onyx-and-iris 2025-06-11 02:09:32 +01:00
parent cb0a87df68
commit e7a561c7b4
5 changed files with 23 additions and 6 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/), 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). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
# [0.7.6] - 2025-06-11
### Added
- --version/-v command.
### Changed
- --token/-t is now required.
# [0.7.3] - 2025-06-10 # [0.7.3] - 2025-06-10
### Added ### Added

View File

@ -46,6 +46,7 @@ The CLI should now be discoverable as `slobs-cli`
- --domain/-d: Streamlabs client domain - --domain/-d: Streamlabs client domain
- --port/-p Streamlabs client port - --port/-p Streamlabs client port
- --token/-t: API Token - --token/-t: API Token
- --version/-v: Print the slobs-cli version
Pass `--domain`, `--port` and `--token` as flags on the root command, for example: Pass `--domain`, `--port` and `--token` as flags on the root command, for example:

View File

@ -1,12 +1,12 @@
[project] [project]
name = "slobs-cli" name = "slobs-cli"
version = "0.7.5"
description = "A command line application for Streamlabs Desktop" description = "A command line application for Streamlabs Desktop"
authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }] authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }]
dependencies = ["pyslobs>=2.0.4", "asyncclick>=8.1.8"] dependencies = ["pyslobs>=2.0.4", "asyncclick>=8.1.8"]
requires-python = ">=3.10" requires-python = ">=3.10"
readme = "README.md" readme = "README.md"
license = { text = "MIT" } license = { text = "MIT" }
dynamic = ["version"]
[project.scripts] [project.scripts]
slobs-cli = "slobs_cli.cli:run" slobs-cli = "slobs_cli.cli:run"
@ -19,6 +19,10 @@ build-backend = "pdm.backend"
[tool.pdm] [tool.pdm]
distribution = true distribution = true
[tool.pdm.version]
source = "file"
path = "src/slobs_cli/__about__.py"
[tool.pdm.scripts] [tool.pdm.scripts]
cli.cmd = "slobs-cli {args}" cli.cmd = "slobs-cli {args}"
cli.env_file = ".env" cli.env_file = ".env"
@ -28,8 +32,4 @@ test.env_file = ".env"
post_test.cmd = "python tests/teardown.py" post_test.cmd = "python tests/teardown.py"
[dependency-groups] [dependency-groups]
dev = [ dev = ["tox-pdm>=0.7.2", "pytest>=8.4.0", "virtualenv-pyenv>=0.5.0"]
"tox-pdm>=0.7.2",
"pytest>=8.4.0",
"virtualenv-pyenv>=0.5.0",
]

View File

@ -0,0 +1 @@
__version__ = "0.7.6"

View File

@ -2,6 +2,8 @@ import anyio
import asyncclick as click import asyncclick as click
from pyslobs import ConnectionConfig, SlobsConnection from pyslobs import ConnectionConfig, SlobsConnection
from .__about__ import __version__ as version
@click.group() @click.group()
@click.option( @click.option(
@ -30,6 +32,9 @@ from pyslobs import ConnectionConfig, SlobsConnection
show_envvar=True, show_envvar=True,
required=True, required=True,
) )
@click.version_option(
version, "-v", "--version", message="%(prog)s version: %(version)s"
)
@click.pass_context @click.pass_context
async def cli(ctx: click.Context, domain: str, port: int, token: str | None): async def cli(ctx: click.Context, domain: str, port: int, token: str | None):
"""Command line interface for Streamlabs Desktop.""" """Command line interface for Streamlabs Desktop."""