mirror of
https://github.com/onyx-and-iris/slobs-cli.git
synced 2026-04-21 00:13:39 +00:00
Compare commits
21 Commits
f282f86e72
...
v0.11.4
| Author | SHA1 | Date | |
|---|---|---|---|
| 4cd420dc44 | |||
| 06c9fa236d | |||
| 6490b5aa54 | |||
| f7345155f1 | |||
| 1c2d1abb2a | |||
| fe3a975ba3 | |||
| d8622ab037 | |||
| 10cb9777fa | |||
| c48f7a49ac | |||
| b14d9b7610 | |||
| 864751ecc9 | |||
| c02ffac403 | |||
| 6bcdd8391c | |||
| b0d311dad9 | |||
| 46159a0ca4 | |||
| 23d3118e6a | |||
| c369f4e3d5 | |||
| 129c3f57f2 | |||
| 42519ba294 | |||
| 09a44b2dea | |||
| f4421b3351 |
26
.github/workflows/release.yml
vendored
Normal file
26
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*.*.*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pypi-publish:
|
||||||
|
name: upload release to PyPI
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment: pypi
|
||||||
|
permissions:
|
||||||
|
# This permission is needed for private repositories.
|
||||||
|
contents: read
|
||||||
|
# IMPORTANT: this permission is mandatory for trusted publishing
|
||||||
|
id-token: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: pdm-project/setup-pdm@v4
|
||||||
|
|
||||||
|
- name: Publish package distributions to PyPI
|
||||||
|
run: pdm publish
|
||||||
16
CHANGELOG.md
16
CHANGELOG.md
@@ -5,6 +5,22 @@ 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.11.0] - 2025-06-22
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Various colouring styles, see [Style](https://github.com/onyx-and-iris/slobs-cli/tree/main?tab=readme-ov-file#style)
|
||||||
|
- colouring is applied to list tables as well as highlighted information in stdout/stderr output.
|
||||||
|
- table border styling may be optionally disabled with the --no-border flag.
|
||||||
|
|
||||||
|
# [0.10.0] - 2025-06-13
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- scene commands are prone to raise ProtocolErrors if called too quickly in succession. To make these errors a little more user friendly the following changes have been made:
|
||||||
|
- They print error messages to stderr
|
||||||
|
- They return exit code 2
|
||||||
|
|
||||||
# [0.9.0] - 2025-06-12
|
# [0.9.0] - 2025-06-12
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
27
README.md
27
README.md
@@ -14,6 +14,7 @@ For an outline of past/future changes refer to: [CHANGELOG](CHANGELOG.md)
|
|||||||
|
|
||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
- [Configuration](#configuration)
|
- [Configuration](#configuration)
|
||||||
|
- [Style](#style)
|
||||||
- [Commands](#commands)
|
- [Commands](#commands)
|
||||||
- [License](#license)
|
- [License](#license)
|
||||||
|
|
||||||
@@ -68,6 +69,30 @@ Flags can be used to override environment variables.
|
|||||||
|
|
||||||
[sl-desktop]: https://streamlabs.com/streamlabs-live-streaming-software?srsltid=AfmBOopnswGBgEyvVSi2DIc_vsGovKn2HQZyLw1Cg6LEo51OJhONXnAX
|
[sl-desktop]: https://streamlabs.com/streamlabs-live-streaming-software?srsltid=AfmBOopnswGBgEyvVSi2DIc_vsGovKn2HQZyLw1Cg6LEo51OJhONXnAX
|
||||||
|
|
||||||
|
## Style
|
||||||
|
|
||||||
|
Styling is opt-in, by default you will get a colourless output:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
You may enable styling with the --style/-s flag:
|
||||||
|
|
||||||
|
```console
|
||||||
|
slobs-cli --style="yellow" audio list
|
||||||
|
```
|
||||||
|
|
||||||
|
Available styles: _red, magenta, purple, blue, cyan, green, yellow, orange, white, grey, navy, black_
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Optionally you may disable the border colouring with the --no-border flag:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
```console
|
||||||
|
slobs-cli --style="yellow' --no-border audio list
|
||||||
|
```
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
#### Scene
|
#### Scene
|
||||||
@@ -299,4 +324,4 @@ slobs-cli scenecollection rename "ExistingCollection" "NewName"
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
`slobs-cli` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
|
`slobs-cli` is distributed under the terms of the [GPL-3.0-or-later](https://spdx.org/licenses/GPL-3.0-or-later.html) license.
|
||||||
BIN
img/coloured-border.png
Executable file
BIN
img/coloured-border.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 4.4 KiB |
BIN
img/coloured-no-border.png
Executable file
BIN
img/coloured-no-border.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 4.4 KiB |
BIN
img/colourless.png
Executable file
BIN
img/colourless.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
118
pdm.lock
generated
118
pdm.lock
generated
@@ -5,7 +5,7 @@
|
|||||||
groups = ["default", "dev"]
|
groups = ["default", "dev"]
|
||||||
strategy = ["inherit_metadata"]
|
strategy = ["inherit_metadata"]
|
||||||
lock_version = "4.5.0"
|
lock_version = "4.5.0"
|
||||||
content_hash = "sha256:c1f6a22d9f4fca9c52692b2931ca64dada84a1e99c9013dad4be26bdd786cc6e"
|
content_hash = "sha256:9be0832aae27a9da3f885900d367836aa05a12e9c0459d751c319d1bd329c33c"
|
||||||
|
|
||||||
[[metadata.targets]]
|
[[metadata.targets]]
|
||||||
requires_python = ">=3.11"
|
requires_python = ">=3.11"
|
||||||
@@ -45,13 +45,13 @@ files = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cachetools"
|
name = "cachetools"
|
||||||
version = "6.0.0"
|
version = "6.1.0"
|
||||||
requires_python = ">=3.9"
|
requires_python = ">=3.9"
|
||||||
summary = "Extensible memoizing collections and decorators"
|
summary = "Extensible memoizing collections and decorators"
|
||||||
groups = ["dev"]
|
groups = ["dev"]
|
||||||
files = [
|
files = [
|
||||||
{file = "cachetools-6.0.0-py3-none-any.whl", hash = "sha256:82e73ba88f7b30228b5507dce1a1f878498fc669d972aef2dde4f3a3c24f103e"},
|
{file = "cachetools-6.1.0-py3-none-any.whl", hash = "sha256:1c7bb3cf9193deaf3508b7c5f2a79986c13ea38965c5adcff1f84519cf39163e"},
|
||||||
{file = "cachetools-6.0.0.tar.gz", hash = "sha256:f225782b84438f828328fc2ad74346522f27e5b1440f4e9fd18b20ebfd1aa2cf"},
|
{file = "cachetools-6.1.0.tar.gz", hash = "sha256:b4c4f404392848db3ce7aac34950d17be4d864da4b8b66911008e430bc544587"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -119,6 +119,31 @@ files = [
|
|||||||
{file = "iniconfig-2.1.0.tar.gz", hash = "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7"},
|
{file = "iniconfig-2.1.0.tar.gz", hash = "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "markdown-it-py"
|
||||||
|
version = "3.0.0"
|
||||||
|
requires_python = ">=3.8"
|
||||||
|
summary = "Python port of markdown-it. Markdown parsing, done right!"
|
||||||
|
groups = ["default"]
|
||||||
|
dependencies = [
|
||||||
|
"mdurl~=0.1",
|
||||||
|
]
|
||||||
|
files = [
|
||||||
|
{file = "markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb"},
|
||||||
|
{file = "markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mdurl"
|
||||||
|
version = "0.1.2"
|
||||||
|
requires_python = ">=3.7"
|
||||||
|
summary = "Markdown URL utilities"
|
||||||
|
groups = ["default"]
|
||||||
|
files = [
|
||||||
|
{file = "mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8"},
|
||||||
|
{file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"},
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "packaging"
|
name = "packaging"
|
||||||
version = "25.0"
|
version = "25.0"
|
||||||
@@ -165,13 +190,13 @@ files = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pygments"
|
name = "pygments"
|
||||||
version = "2.19.1"
|
version = "2.19.2"
|
||||||
requires_python = ">=3.8"
|
requires_python = ">=3.8"
|
||||||
summary = "Pygments is a syntax highlighting package written in Python."
|
summary = "Pygments is a syntax highlighting package written in Python."
|
||||||
groups = ["dev"]
|
groups = ["default", "dev"]
|
||||||
files = [
|
files = [
|
||||||
{file = "pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c"},
|
{file = "pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b"},
|
||||||
{file = "pygments-2.19.1.tar.gz", hash = "sha256:61c16d2a8576dc0649d9f39e089b5f02bcd27fba10d8fb4dcc28173f7a45151f"},
|
{file = "pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -205,7 +230,7 @@ files = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pytest"
|
name = "pytest"
|
||||||
version = "8.4.0"
|
version = "8.4.1"
|
||||||
requires_python = ">=3.9"
|
requires_python = ">=3.9"
|
||||||
summary = "pytest: simple powerful testing with Python"
|
summary = "pytest: simple powerful testing with Python"
|
||||||
groups = ["dev"]
|
groups = ["dev"]
|
||||||
@@ -219,8 +244,8 @@ dependencies = [
|
|||||||
"tomli>=1; python_version < \"3.11\"",
|
"tomli>=1; python_version < \"3.11\"",
|
||||||
]
|
]
|
||||||
files = [
|
files = [
|
||||||
{file = "pytest-8.4.0-py3-none-any.whl", hash = "sha256:f40f825768ad76c0977cbacdf1fd37c6f7a468e460ea6a0636078f8972d4517e"},
|
{file = "pytest-8.4.1-py3-none-any.whl", hash = "sha256:539c70ba6fcead8e78eebbf1115e8b589e7565830d7d006a8723f19ac8a0afb7"},
|
||||||
{file = "pytest-8.4.0.tar.gz", hash = "sha256:14d920b48472ea0dbf68e45b96cd1ffda4705f33307dcc86c676c1b5104838a6"},
|
{file = "pytest-8.4.1.tar.gz", hash = "sha256:7c67fd69174877359ed9371ec3af8a3d2b04741818c51e5e99cc1742251fa93c"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -238,31 +263,47 @@ files = [
|
|||||||
{file = "pytest_randomly-3.16.0.tar.gz", hash = "sha256:11bf4d23a26484de7860d82f726c0629837cf4064b79157bd18ec9d41d7feb26"},
|
{file = "pytest_randomly-3.16.0.tar.gz", hash = "sha256:11bf4d23a26484de7860d82f726c0629837cf4064b79157bd18ec9d41d7feb26"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rich"
|
||||||
|
version = "14.0.0"
|
||||||
|
requires_python = ">=3.8.0"
|
||||||
|
summary = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
|
||||||
|
groups = ["default"]
|
||||||
|
dependencies = [
|
||||||
|
"markdown-it-py>=2.2.0",
|
||||||
|
"pygments<3.0.0,>=2.13.0",
|
||||||
|
"typing-extensions<5.0,>=4.0.0; python_version < \"3.11\"",
|
||||||
|
]
|
||||||
|
files = [
|
||||||
|
{file = "rich-14.0.0-py3-none-any.whl", hash = "sha256:1c9491e1951aac09caffd42f448ee3d04e58923ffe14993f6e83068dc395d7e0"},
|
||||||
|
{file = "rich-14.0.0.tar.gz", hash = "sha256:82f1bc23a6a21ebca4ae0c45af9bdbc492ed20231dcb63f297d6d1021a9d5725"},
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruff"
|
name = "ruff"
|
||||||
version = "0.11.13"
|
version = "0.12.1"
|
||||||
requires_python = ">=3.7"
|
requires_python = ">=3.7"
|
||||||
summary = "An extremely fast Python linter and code formatter, written in Rust."
|
summary = "An extremely fast Python linter and code formatter, written in Rust."
|
||||||
groups = ["dev"]
|
groups = ["dev"]
|
||||||
files = [
|
files = [
|
||||||
{file = "ruff-0.11.13-py3-none-linux_armv6l.whl", hash = "sha256:4bdfbf1240533f40042ec00c9e09a3aade6f8c10b6414cf11b519488d2635d46"},
|
{file = "ruff-0.12.1-py3-none-linux_armv6l.whl", hash = "sha256:6013a46d865111e2edb71ad692fbb8262e6c172587a57c0669332a449384a36b"},
|
||||||
{file = "ruff-0.11.13-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:aef9c9ed1b5ca28bb15c7eac83b8670cf3b20b478195bd49c8d756ba0a36cf48"},
|
{file = "ruff-0.12.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b3f75a19e03a4b0757d1412edb7f27cffb0c700365e9d6b60bc1b68d35bc89e0"},
|
||||||
{file = "ruff-0.11.13-py3-none-macosx_11_0_arm64.whl", hash = "sha256:53b15a9dfdce029c842e9a5aebc3855e9ab7771395979ff85b7c1dedb53ddc2b"},
|
{file = "ruff-0.12.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:9a256522893cb7e92bb1e1153283927f842dea2e48619c803243dccc8437b8be"},
|
||||||
{file = "ruff-0.11.13-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ab153241400789138d13f362c43f7edecc0edfffce2afa6a68434000ecd8f69a"},
|
{file = "ruff-0.12.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:069052605fe74c765a5b4272eb89880e0ff7a31e6c0dbf8767203c1fbd31c7ff"},
|
||||||
{file = "ruff-0.11.13-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:6c51f93029d54a910d3d24f7dd0bb909e31b6cd989a5e4ac513f4eb41629f0dc"},
|
{file = "ruff-0.12.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:a684f125a4fec2d5a6501a466be3841113ba6847827be4573fddf8308b83477d"},
|
||||||
{file = "ruff-0.11.13-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1808b3ed53e1a777c2ef733aca9051dc9bf7c99b26ece15cb59a0320fbdbd629"},
|
{file = "ruff-0.12.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:bdecdef753bf1e95797593007569d8e1697a54fca843d78f6862f7dc279e23bd"},
|
||||||
{file = "ruff-0.11.13-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:d28ce58b5ecf0f43c1b71edffabe6ed7f245d5336b17805803312ec9bc665933"},
|
{file = "ruff-0.12.1-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:70d52a058c0e7b88b602f575d23596e89bd7d8196437a4148381a3f73fcd5010"},
|
||||||
{file = "ruff-0.11.13-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:55e4bc3a77842da33c16d55b32c6cac1ec5fb0fbec9c8c513bdce76c4f922165"},
|
{file = "ruff-0.12.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:84d0a69d1e8d716dfeab22d8d5e7c786b73f2106429a933cee51d7b09f861d4e"},
|
||||||
{file = "ruff-0.11.13-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:633bf2c6f35678c56ec73189ba6fa19ff1c5e4807a78bf60ef487b9dd272cc71"},
|
{file = "ruff-0.12.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6cc32e863adcf9e71690248607ccdf25252eeeab5193768e6873b901fd441fed"},
|
||||||
{file = "ruff-0.11.13-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4ffbc82d70424b275b089166310448051afdc6e914fdab90e08df66c43bb5ca9"},
|
{file = "ruff-0.12.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7fd49a4619f90d5afc65cf42e07b6ae98bb454fd5029d03b306bd9e2273d44cc"},
|
||||||
{file = "ruff-0.11.13-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:4a9ddd3ec62a9a89578c85842b836e4ac832d4a2e0bfaad3b02243f930ceafcc"},
|
{file = "ruff-0.12.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:ed5af6aaaea20710e77698e2055b9ff9b3494891e1b24d26c07055459bb717e9"},
|
||||||
{file = "ruff-0.11.13-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:d237a496e0778d719efb05058c64d28b757c77824e04ffe8796c7436e26712b7"},
|
{file = "ruff-0.12.1-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:801d626de15e6bf988fbe7ce59b303a914ff9c616d5866f8c79eb5012720ae13"},
|
||||||
{file = "ruff-0.11.13-py3-none-musllinux_1_2_i686.whl", hash = "sha256:26816a218ca6ef02142343fd24c70f7cd8c5aa6c203bca284407adf675984432"},
|
{file = "ruff-0.12.1-py3-none-musllinux_1_2_i686.whl", hash = "sha256:2be9d32a147f98a1972c1e4df9a6956d612ca5f5578536814372113d09a27a6c"},
|
||||||
{file = "ruff-0.11.13-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:51c3f95abd9331dc5b87c47ac7f376db5616041173826dfd556cfe3d4977f492"},
|
{file = "ruff-0.12.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:49b7ce354eed2a322fbaea80168c902de9504e6e174fd501e9447cad0232f9e6"},
|
||||||
{file = "ruff-0.11.13-py3-none-win32.whl", hash = "sha256:96c27935418e4e8e77a26bb05962817f28b8ef3843a6c6cc49d8783b5507f250"},
|
{file = "ruff-0.12.1-py3-none-win32.whl", hash = "sha256:d973fa626d4c8267848755bd0414211a456e99e125dcab147f24daa9e991a245"},
|
||||||
{file = "ruff-0.11.13-py3-none-win_amd64.whl", hash = "sha256:29c3189895a8a6a657b7af4e97d330c8a3afd2c9c8f46c81e2fc5a31866517e3"},
|
{file = "ruff-0.12.1-py3-none-win_amd64.whl", hash = "sha256:9e1123b1c033f77bd2590e4c1fe7e8ea72ef990a85d2484351d408224d603013"},
|
||||||
{file = "ruff-0.11.13-py3-none-win_arm64.whl", hash = "sha256:b4385285e9179d608ff1d2fb9922062663c658605819a6876d8beef0c30b7f3b"},
|
{file = "ruff-0.12.1-py3-none-win_arm64.whl", hash = "sha256:78ad09a022c64c13cc6077707f036bab0fac8cd7088772dcd1e5be21c5002efc"},
|
||||||
{file = "ruff-0.11.13.tar.gz", hash = "sha256:26fa247dc68d1d4e72c179e08889a25ac0c7ba4d78aecfc835d49cbfd60bf514"},
|
{file = "ruff-0.12.1.tar.gz", hash = "sha256:806bbc17f1104fd57451a98a58df35388ee3ab422e029e8f5cf30aa4af2c138c"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -276,20 +317,9 @@ files = [
|
|||||||
{file = "sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"},
|
{file = "sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "terminaltables3"
|
|
||||||
version = "4.0.0"
|
|
||||||
requires_python = ">=3.8"
|
|
||||||
summary = "Generate simple tables in terminals from a nested list of strings. Fork of terminaltables."
|
|
||||||
groups = ["default"]
|
|
||||||
files = [
|
|
||||||
{file = "terminaltables3-4.0.0-py3-none-any.whl", hash = "sha256:93b4c722f35400a7869cd630e2bbab616b129d1c47c628765c7f47baab2ca270"},
|
|
||||||
{file = "terminaltables3-4.0.0.tar.gz", hash = "sha256:4e3eefe209aa89005a0a34d1525739424569729ee29b5e64a8dd51c5ebdab77f"},
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tox"
|
name = "tox"
|
||||||
version = "4.26.0"
|
version = "4.27.0"
|
||||||
requires_python = ">=3.9"
|
requires_python = ">=3.9"
|
||||||
summary = "tox is a generic virtualenv management and test command line tool"
|
summary = "tox is a generic virtualenv management and test command line tool"
|
||||||
groups = ["dev"]
|
groups = ["dev"]
|
||||||
@@ -307,8 +337,8 @@ dependencies = [
|
|||||||
"virtualenv>=20.31",
|
"virtualenv>=20.31",
|
||||||
]
|
]
|
||||||
files = [
|
files = [
|
||||||
{file = "tox-4.26.0-py3-none-any.whl", hash = "sha256:75f17aaf09face9b97bd41645028d9f722301e912be8b4c65a3f938024560224"},
|
{file = "tox-4.27.0-py3-none-any.whl", hash = "sha256:2b8a7fb986b82aa2c830c0615082a490d134e0626dbc9189986da46a313c4f20"},
|
||||||
{file = "tox-4.26.0.tar.gz", hash = "sha256:a83b3b67b0159fa58e44e646505079e35a43317a62d2ae94725e0586266faeca"},
|
{file = "tox-4.27.0.tar.gz", hash = "sha256:b97d5ecc0c0d5755bcc5348387fef793e1bfa68eb33746412f4c60881d7f5f57"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
name = "slobs-cli"
|
name = "slobs-cli"
|
||||||
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.5", "asyncclick>=8.1.8", "terminaltables3>=4.0.0"]
|
dependencies = ["pyslobs>=2.0.5", "asyncclick>=8.1.8", "rich>=14.0.0"]
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = { text = "MIT" }
|
license = { text = "MIT" }
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
"""module for package metadata."""
|
"""module for package metadata."""
|
||||||
|
|
||||||
__version__ = '0.9.3'
|
__version__ = '0.11.4'
|
||||||
|
|||||||
@@ -3,8 +3,10 @@
|
|||||||
import asyncclick as click
|
import asyncclick as click
|
||||||
from anyio import create_task_group
|
from anyio import create_task_group
|
||||||
from pyslobs import AudioService
|
from pyslobs import AudioService
|
||||||
from terminaltables3 import AsciiTable
|
from rich.table import Table
|
||||||
|
from rich.text import Text
|
||||||
|
|
||||||
|
from . import console, util
|
||||||
from .cli import cli
|
from .cli import cli
|
||||||
from .errors import SlobsCliError
|
from .errors import SlobsCliError
|
||||||
|
|
||||||
@@ -25,32 +27,40 @@ async def list(ctx: click.Context, id: bool = False):
|
|||||||
async def _run():
|
async def _run():
|
||||||
sources = await as_.get_sources()
|
sources = await as_.get_sources()
|
||||||
if not sources:
|
if not sources:
|
||||||
click.echo('No audio sources found.')
|
console.out.print('No audio sources found.')
|
||||||
conn.close()
|
conn.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
table_data = [
|
style = ctx.obj['style']
|
||||||
['Audio Device Name', 'ID', 'Muted']
|
table = Table(
|
||||||
if id
|
show_header=True, header_style=style.header, border_style=style.border
|
||||||
else ['Audio Device Name', 'Muted']
|
)
|
||||||
]
|
|
||||||
|
if id:
|
||||||
|
columns = [
|
||||||
|
('Audio Source Name', 'left'),
|
||||||
|
('Muted', 'center'),
|
||||||
|
('ID', 'left'),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
columns = [
|
||||||
|
('Audio Source Name', 'left'),
|
||||||
|
('Muted', 'center'),
|
||||||
|
]
|
||||||
|
for heading, justify in columns:
|
||||||
|
table.add_column(Text(heading, justify='center'), justify=justify)
|
||||||
|
|
||||||
for source in sources:
|
for source in sources:
|
||||||
model = await source.get_model()
|
model = await source.get_model()
|
||||||
|
|
||||||
to_append = [click.style(model.name, fg='blue')]
|
to_append = [Text(model.name, style=style.cell)]
|
||||||
|
to_append.append(util.check_mark(ctx, model.muted))
|
||||||
if id:
|
if id:
|
||||||
to_append.append(model.source_id)
|
to_append.append(Text(model.source_id, style=style.cell))
|
||||||
to_append.append('✅' if model.muted else '❌')
|
|
||||||
|
|
||||||
table_data.append(to_append)
|
table.add_row(*to_append)
|
||||||
|
|
||||||
table = AsciiTable(table_data)
|
console.out.print(table)
|
||||||
table.justify_columns = {
|
|
||||||
0: 'left',
|
|
||||||
1: 'left' if id else 'center',
|
|
||||||
2: 'center' if id else None,
|
|
||||||
}
|
|
||||||
click.echo(table.table)
|
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
@@ -78,7 +88,7 @@ async def mute(ctx: click.Context, source_name: str):
|
|||||||
raise SlobsCliError(f'Audio source "{source_name}" not found.')
|
raise SlobsCliError(f'Audio source "{source_name}" not found.')
|
||||||
|
|
||||||
await source.set_muted(True)
|
await source.set_muted(True)
|
||||||
click.echo(f'{source_name} muted successfully.')
|
console.out.print(f'{console.highlight(ctx, source_name)} muted successfully.')
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -86,8 +96,8 @@ async def mute(ctx: click.Context, source_name: str):
|
|||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
tg.start_soon(_run)
|
tg.start_soon(_run)
|
||||||
except* SlobsCliError as excgroup:
|
except* SlobsCliError as excgroup:
|
||||||
for e in excgroup.exceptions:
|
raisable = next(iter(excgroup.exceptions))
|
||||||
raise e
|
raise raisable
|
||||||
|
|
||||||
|
|
||||||
@audio.command()
|
@audio.command()
|
||||||
@@ -109,7 +119,9 @@ async def unmute(ctx: click.Context, source_name: str):
|
|||||||
raise SlobsCliError(f'Audio source "{source_name}" not found.')
|
raise SlobsCliError(f'Audio source "{source_name}" not found.')
|
||||||
|
|
||||||
await source.set_muted(False)
|
await source.set_muted(False)
|
||||||
click.echo(f'{source_name} unmuted successfully.')
|
console.out.print(
|
||||||
|
f'{console.highlight(ctx, source_name)} unmuted successfully.'
|
||||||
|
)
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -117,8 +129,8 @@ async def unmute(ctx: click.Context, source_name: str):
|
|||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
tg.start_soon(_run)
|
tg.start_soon(_run)
|
||||||
except* SlobsCliError as excgroup:
|
except* SlobsCliError as excgroup:
|
||||||
for e in excgroup.exceptions:
|
raisable = next(iter(excgroup.exceptions))
|
||||||
raise e
|
raise raisable
|
||||||
|
|
||||||
|
|
||||||
@audio.command()
|
@audio.command()
|
||||||
@@ -136,10 +148,14 @@ async def toggle(ctx: click.Context, source_name: str):
|
|||||||
if model.name.lower() == source_name.lower():
|
if model.name.lower() == source_name.lower():
|
||||||
if model.muted:
|
if model.muted:
|
||||||
await source.set_muted(False)
|
await source.set_muted(False)
|
||||||
click.echo(f'{source_name} unmuted successfully.')
|
console.out.print(
|
||||||
|
f'{console.highlight(ctx, source_name)} unmuted successfully.'
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
await source.set_muted(True)
|
await source.set_muted(True)
|
||||||
click.echo(f'{source_name} muted successfully.')
|
console.out.print(
|
||||||
|
f'{console.highlight(ctx, source_name)} muted successfully.'
|
||||||
|
)
|
||||||
conn.close()
|
conn.close()
|
||||||
break
|
break
|
||||||
else: # If no source by the given name was found
|
else: # If no source by the given name was found
|
||||||
@@ -151,8 +167,8 @@ async def toggle(ctx: click.Context, source_name: str):
|
|||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
tg.start_soon(_run)
|
tg.start_soon(_run)
|
||||||
except* SlobsCliError as excgroup:
|
except* SlobsCliError as excgroup:
|
||||||
for e in excgroup.exceptions:
|
raisable = next(iter(excgroup.exceptions))
|
||||||
raise e
|
raise raisable
|
||||||
|
|
||||||
|
|
||||||
@audio.command()
|
@audio.command()
|
||||||
@@ -168,12 +184,12 @@ async def status(ctx: click.Context, source_name: str):
|
|||||||
for source in sources:
|
for source in sources:
|
||||||
model = await source.get_model()
|
model = await source.get_model()
|
||||||
if model.name.lower() == source_name.lower():
|
if model.name.lower() == source_name.lower():
|
||||||
click.echo(
|
console.out.print(
|
||||||
f'"{source_name}" is {"muted" if model.muted else "unmuted"}.'
|
f'{console.highlight(ctx, source_name)} is {"muted" if model.muted else "unmuted"}.'
|
||||||
)
|
)
|
||||||
conn.close()
|
conn.close()
|
||||||
return
|
return
|
||||||
else:
|
else: # If no source by the given name was found
|
||||||
conn.close()
|
conn.close()
|
||||||
raise SlobsCliError(f'Audio source "{source_name}" not found.')
|
raise SlobsCliError(f'Audio source "{source_name}" not found.')
|
||||||
|
|
||||||
@@ -182,5 +198,5 @@ async def status(ctx: click.Context, source_name: str):
|
|||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
tg.start_soon(_run)
|
tg.start_soon(_run)
|
||||||
except* SlobsCliError as excgroup:
|
except* SlobsCliError as excgroup:
|
||||||
for e in excgroup.exceptions:
|
raisable = next(iter(excgroup.exceptions))
|
||||||
raise e
|
raise raisable
|
||||||
|
|||||||
@@ -4,10 +4,25 @@ import anyio
|
|||||||
import asyncclick as click
|
import asyncclick as click
|
||||||
from pyslobs import ConnectionConfig, SlobsConnection
|
from pyslobs import ConnectionConfig, SlobsConnection
|
||||||
|
|
||||||
|
from . import styles
|
||||||
from .__about__ import __version__ as version
|
from .__about__ import __version__ as version
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
def validate_style(ctx: click.Context, param: click.Parameter, value: str) -> str:
|
||||||
|
"""Validate the style option."""
|
||||||
|
if value not in styles.registry:
|
||||||
|
raise click.BadParameter(
|
||||||
|
f"Invalid style '{value}'. Available styles: {', '.join(styles.registry.keys())}"
|
||||||
|
)
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
|
||||||
|
|
||||||
|
|
||||||
|
@click.group(
|
||||||
|
context_settings=CONTEXT_SETTINGS,
|
||||||
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
'-d',
|
'-d',
|
||||||
'--domain',
|
'--domain',
|
||||||
@@ -15,7 +30,7 @@ from .__about__ import __version__ as version
|
|||||||
envvar='SLOBS_DOMAIN',
|
envvar='SLOBS_DOMAIN',
|
||||||
show_default=True,
|
show_default=True,
|
||||||
show_envvar=True,
|
show_envvar=True,
|
||||||
help='The domain of the SLOBS server.',
|
help='\b\nStreamlabs Desktop WebSocket domain or IP address.\t',
|
||||||
)
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
'-p',
|
'-p',
|
||||||
@@ -24,7 +39,7 @@ from .__about__ import __version__ as version
|
|||||||
envvar='SLOBS_PORT',
|
envvar='SLOBS_PORT',
|
||||||
show_default=True,
|
show_default=True,
|
||||||
show_envvar=True,
|
show_envvar=True,
|
||||||
help='The port of the SLOBS server.',
|
help='\b\nStreamlabs Desktop WebSocket port.\t\t\t',
|
||||||
)
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
'-t',
|
'-t',
|
||||||
@@ -32,13 +47,35 @@ from .__about__ import __version__ as version
|
|||||||
envvar='SLOBS_TOKEN',
|
envvar='SLOBS_TOKEN',
|
||||||
show_envvar=True,
|
show_envvar=True,
|
||||||
required=True,
|
required=True,
|
||||||
help='The token for the SLOBS server.',
|
help='\b\nStreamlabs Desktop WebSocket authentication token.\t',
|
||||||
|
)
|
||||||
|
@click.option(
|
||||||
|
'-s',
|
||||||
|
'--style',
|
||||||
|
default='disabled',
|
||||||
|
envvar='SLOBS_STYLE',
|
||||||
|
show_default=True,
|
||||||
|
show_envvar=True,
|
||||||
|
help='\b\nThe style to use for output.\t\t\t\t',
|
||||||
|
callback=validate_style,
|
||||||
|
)
|
||||||
|
@click.option(
|
||||||
|
'-b',
|
||||||
|
'--no-border',
|
||||||
|
is_flag=True,
|
||||||
|
default=False,
|
||||||
|
envvar='SLOBS_STYLE_NO_BORDER',
|
||||||
|
show_default=True,
|
||||||
|
show_envvar=True,
|
||||||
|
help='\b\nDisable borders in the output.\t\t\t\t',
|
||||||
)
|
)
|
||||||
@click.version_option(
|
@click.version_option(
|
||||||
version, '-v', '--version', message='%(prog)s version: %(version)s'
|
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):
|
async def cli(
|
||||||
|
ctx: click.Context, domain: str, port: int, token: str, style: str, no_border: bool
|
||||||
|
):
|
||||||
"""Command line interface for Streamlabs Desktop."""
|
"""Command line interface for Streamlabs Desktop."""
|
||||||
ctx.ensure_object(dict)
|
ctx.ensure_object(dict)
|
||||||
config = ConnectionConfig(
|
config = ConnectionConfig(
|
||||||
@@ -47,6 +84,7 @@ async def cli(ctx: click.Context, domain: str, port: int, token: str):
|
|||||||
token=token,
|
token=token,
|
||||||
)
|
)
|
||||||
ctx.obj['connection'] = SlobsConnection(config)
|
ctx.obj['connection'] = SlobsConnection(config)
|
||||||
|
ctx.obj['style'] = styles.request_style_obj(style, no_border)
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
|||||||
17
src/slobs_cli/console.py
Normal file
17
src/slobs_cli/console.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
"""module for console output handling."""
|
||||||
|
|
||||||
|
import asyncclick as click
|
||||||
|
from rich.console import Console
|
||||||
|
|
||||||
|
out = Console()
|
||||||
|
err = Console(stderr=True, style='bold red')
|
||||||
|
|
||||||
|
|
||||||
|
def highlight(ctx: click.Context, text: str) -> str:
|
||||||
|
"""Highlight text for console output."""
|
||||||
|
return f'[{ctx.obj["style"].highlight}]{text}[/{ctx.obj["style"].highlight}]'
|
||||||
|
|
||||||
|
|
||||||
|
def warning(ctx: click.Context, text: str) -> str:
|
||||||
|
"""Format warning text for console output."""
|
||||||
|
return f'[{ctx.obj["style"].warning}]{text}[/{ctx.obj["style"].warning}]'
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
"""module for custom exceptions in Slobs CLI."""
|
"""module for custom exceptions in Slobs CLI."""
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
import asyncclick as click
|
import asyncclick as click
|
||||||
|
|
||||||
|
from . import console
|
||||||
|
|
||||||
|
|
||||||
class SlobsCliError(click.ClickException):
|
class SlobsCliError(click.ClickException):
|
||||||
"""Base class for all Slobs CLI errors."""
|
"""Base class for all Slobs CLI errors."""
|
||||||
@@ -12,5 +16,31 @@ class SlobsCliError(click.ClickException):
|
|||||||
self.exit_code = 1
|
self.exit_code = 1
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
"""Display the error message in red."""
|
"""Display the error message in red and write to stderr."""
|
||||||
click.secho(f'Error: {self.message}', fg='red', err=True)
|
console.err.print(f'Error: {self.message}')
|
||||||
|
|
||||||
|
|
||||||
|
class SlobsCliProtocolError(SlobsCliError):
|
||||||
|
"""Converts pyslobs ProtocolError to a SlobsCliProtocolError."""
|
||||||
|
|
||||||
|
def __init__(self, message: str):
|
||||||
|
"""Initialize the SlobsCliProtocolError with a message."""
|
||||||
|
protocol_message_to_dict = json.loads(
|
||||||
|
str(message).replace('"', '\\"').replace("'", '"')
|
||||||
|
)
|
||||||
|
super().__init__(
|
||||||
|
protocol_message_to_dict.get('message', 'Unable to parse error message')
|
||||||
|
)
|
||||||
|
self.exit_code = 2
|
||||||
|
self.protocol_code = protocol_message_to_dict.get('code', 'Unknown error code')
|
||||||
|
|
||||||
|
def show(self):
|
||||||
|
"""Display the protocol error message in red."""
|
||||||
|
match self.protocol_code:
|
||||||
|
case -32600:
|
||||||
|
console.err.print(
|
||||||
|
'Oops! Looks like we hit a rate limit for this command. Please try again later.'
|
||||||
|
)
|
||||||
|
case _:
|
||||||
|
# Fall back to the base error display for unknown protocol codes
|
||||||
|
super().show()
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import asyncclick as click
|
|||||||
from anyio import create_task_group
|
from anyio import create_task_group
|
||||||
from pyslobs import StreamingService
|
from pyslobs import StreamingService
|
||||||
|
|
||||||
|
from . import console
|
||||||
from .cli import cli
|
from .cli import cli
|
||||||
from .errors import SlobsCliError
|
from .errors import SlobsCliError
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ async def start(ctx: click.Context):
|
|||||||
raise SlobsCliError('Recording is already active.')
|
raise SlobsCliError('Recording is already active.')
|
||||||
|
|
||||||
await ss.toggle_recording()
|
await ss.toggle_recording()
|
||||||
click.echo('Recording started.')
|
console.out.print('Recording started.')
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
@@ -38,8 +39,8 @@ async def start(ctx: click.Context):
|
|||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
tg.start_soon(_run)
|
tg.start_soon(_run)
|
||||||
except* SlobsCliError as excgroup:
|
except* SlobsCliError as excgroup:
|
||||||
for e in excgroup.exceptions:
|
raisable = next(iter(excgroup.exceptions))
|
||||||
raise e
|
raise raisable
|
||||||
|
|
||||||
|
|
||||||
@record.command()
|
@record.command()
|
||||||
@@ -58,7 +59,7 @@ async def stop(ctx: click.Context):
|
|||||||
raise SlobsCliError('Recording is already inactive.')
|
raise SlobsCliError('Recording is already inactive.')
|
||||||
|
|
||||||
await ss.toggle_recording()
|
await ss.toggle_recording()
|
||||||
click.echo('Recording stopped.')
|
console.out.print('Recording stopped.')
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
@@ -67,8 +68,8 @@ async def stop(ctx: click.Context):
|
|||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
tg.start_soon(_run)
|
tg.start_soon(_run)
|
||||||
except* SlobsCliError as excgroup:
|
except* SlobsCliError as excgroup:
|
||||||
for e in excgroup.exceptions:
|
raisable = next(iter(excgroup.exceptions))
|
||||||
raise e
|
raise raisable
|
||||||
|
|
||||||
|
|
||||||
@record.command()
|
@record.command()
|
||||||
@@ -83,9 +84,9 @@ async def status(ctx: click.Context):
|
|||||||
active = model.recording_status != 'offline'
|
active = model.recording_status != 'offline'
|
||||||
|
|
||||||
if active:
|
if active:
|
||||||
click.echo('Recording is currently active.')
|
console.out.print('Recording is currently active.')
|
||||||
else:
|
else:
|
||||||
click.echo('Recording is currently inactive.')
|
console.out.print('Recording is currently inactive.')
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
@@ -107,9 +108,9 @@ async def toggle(ctx: click.Context):
|
|||||||
|
|
||||||
await ss.toggle_recording()
|
await ss.toggle_recording()
|
||||||
if active:
|
if active:
|
||||||
click.echo('Recording stopped.')
|
console.out.print('Recording stopped.')
|
||||||
else:
|
else:
|
||||||
click.echo('Recording started.')
|
console.out.print('Recording started.')
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import asyncclick as click
|
|||||||
from anyio import create_task_group
|
from anyio import create_task_group
|
||||||
from pyslobs import StreamingService
|
from pyslobs import StreamingService
|
||||||
|
|
||||||
|
from . import console
|
||||||
from .cli import cli
|
from .cli import cli
|
||||||
from .errors import SlobsCliError
|
from .errors import SlobsCliError
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ async def start(ctx: click.Context):
|
|||||||
raise SlobsCliError('Replay buffer is already active.')
|
raise SlobsCliError('Replay buffer is already active.')
|
||||||
|
|
||||||
await ss.start_replay_buffer()
|
await ss.start_replay_buffer()
|
||||||
click.echo('Replay buffer started.')
|
console.out.print('Replay buffer started.')
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -37,8 +38,8 @@ async def start(ctx: click.Context):
|
|||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
tg.start_soon(_run)
|
tg.start_soon(_run)
|
||||||
except* SlobsCliError as excgroup:
|
except* SlobsCliError as excgroup:
|
||||||
for e in excgroup.exceptions:
|
raisable = next(iter(excgroup.exceptions))
|
||||||
raise e
|
raise raisable
|
||||||
|
|
||||||
|
|
||||||
@replaybuffer.command()
|
@replaybuffer.command()
|
||||||
@@ -57,7 +58,7 @@ async def stop(ctx: click.Context):
|
|||||||
raise SlobsCliError('Replay buffer is already inactive.')
|
raise SlobsCliError('Replay buffer is already inactive.')
|
||||||
|
|
||||||
await ss.stop_replay_buffer()
|
await ss.stop_replay_buffer()
|
||||||
click.echo('Replay buffer stopped.')
|
console.out.print('Replay buffer stopped.')
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -65,8 +66,8 @@ async def stop(ctx: click.Context):
|
|||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
tg.start_soon(_run)
|
tg.start_soon(_run)
|
||||||
except* SlobsCliError as excgroup:
|
except* SlobsCliError as excgroup:
|
||||||
for e in excgroup.exceptions:
|
raisable = next(iter(excgroup.exceptions))
|
||||||
raise e
|
raise raisable
|
||||||
|
|
||||||
|
|
||||||
@replaybuffer.command()
|
@replaybuffer.command()
|
||||||
@@ -80,9 +81,9 @@ async def status(ctx: click.Context):
|
|||||||
model = await ss.get_model()
|
model = await ss.get_model()
|
||||||
active = model.replay_buffer_status != 'offline'
|
active = model.replay_buffer_status != 'offline'
|
||||||
if active:
|
if active:
|
||||||
click.echo('Replay buffer is currently active.')
|
console.out.print('Replay buffer is currently active.')
|
||||||
else:
|
else:
|
||||||
click.echo('Replay buffer is currently inactive.')
|
console.out.print('Replay buffer is currently inactive.')
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
async with create_task_group() as tg:
|
async with create_task_group() as tg:
|
||||||
@@ -99,7 +100,7 @@ async def save(ctx: click.Context):
|
|||||||
|
|
||||||
async def _run():
|
async def _run():
|
||||||
await ss.save_replay()
|
await ss.save_replay()
|
||||||
click.echo('Replay buffer saved.')
|
console.out.print('Replay buffer saved.')
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
async with create_task_group() as tg:
|
async with create_task_group() as tg:
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
|
|
||||||
import asyncclick as click
|
import asyncclick as click
|
||||||
from anyio import create_task_group
|
from anyio import create_task_group
|
||||||
from pyslobs import ScenesService, TransitionsService
|
from pyslobs import ProtocolError, ScenesService, TransitionsService
|
||||||
from terminaltables3 import AsciiTable
|
from rich.table import Table
|
||||||
|
from rich.text import Text
|
||||||
|
|
||||||
|
from . import console, util
|
||||||
from .cli import cli
|
from .cli import cli
|
||||||
from .errors import SlobsCliError
|
from .errors import SlobsCliError, SlobsCliProtocolError
|
||||||
|
|
||||||
|
|
||||||
@cli.group()
|
@cli.group()
|
||||||
@@ -25,40 +27,56 @@ async def list(ctx: click.Context, id: bool = False):
|
|||||||
async def _run():
|
async def _run():
|
||||||
scenes = await ss.get_scenes()
|
scenes = await ss.get_scenes()
|
||||||
if not scenes:
|
if not scenes:
|
||||||
click.echo('No scenes found.')
|
console.out.print('No scenes found.')
|
||||||
conn.close()
|
conn.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
active_scene = await ss.active_scene()
|
active_scene = await ss.active_scene()
|
||||||
|
|
||||||
table_data = [
|
style = ctx.obj['style']
|
||||||
['Scene Name', 'ID', 'Active'] if id else ['Scene Name', 'Active']
|
table = Table(
|
||||||
]
|
show_header=True,
|
||||||
|
header_style=style.header,
|
||||||
|
border_style=style.border,
|
||||||
|
)
|
||||||
|
|
||||||
|
if id:
|
||||||
|
columns = [
|
||||||
|
('Scene Name', 'left'),
|
||||||
|
('Active', 'center'),
|
||||||
|
('ID', 'left'),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
columns = [
|
||||||
|
('Scene Name', 'left'),
|
||||||
|
('Active', 'center'),
|
||||||
|
]
|
||||||
|
|
||||||
|
for heading, justify in columns:
|
||||||
|
table.add_column(Text(heading, justify='center'), justify=justify)
|
||||||
|
|
||||||
for scene in scenes:
|
for scene in scenes:
|
||||||
if scene.id == active_scene.id:
|
to_append = [Text(scene.name, style=style.cell)]
|
||||||
to_append = [click.style(scene.name, fg='green')]
|
to_append.append(
|
||||||
else:
|
util.check_mark(ctx, scene.id == active_scene.id, empty_if_false=True)
|
||||||
to_append = [click.style(scene.name, fg='blue')]
|
)
|
||||||
if id:
|
if id:
|
||||||
to_append.append(scene.id)
|
to_append.append(Text(scene.id, style=style.cell))
|
||||||
if scene.id == active_scene.id:
|
|
||||||
to_append.append('✅')
|
|
||||||
|
|
||||||
table_data.append(to_append)
|
table.add_row(*to_append)
|
||||||
|
|
||||||
table = AsciiTable(table_data)
|
console.out.print(table)
|
||||||
table.justify_columns = {
|
|
||||||
0: 'left',
|
|
||||||
1: 'left' if id else 'center',
|
|
||||||
2: 'center' if id else None,
|
|
||||||
}
|
|
||||||
click.echo(table.table)
|
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
async with create_task_group() as tg:
|
try:
|
||||||
tg.start_soon(conn.background_processing)
|
async with create_task_group() as tg:
|
||||||
tg.start_soon(_run)
|
tg.start_soon(conn.background_processing)
|
||||||
|
tg.start_soon(_run)
|
||||||
|
except* ProtocolError as excgroup:
|
||||||
|
p_error = next(iter(excgroup.exceptions))
|
||||||
|
raisable = SlobsCliProtocolError(str(p_error))
|
||||||
|
raise raisable
|
||||||
|
|
||||||
|
|
||||||
@scene.command()
|
@scene.command()
|
||||||
@@ -71,15 +89,20 @@ async def current(ctx: click.Context, id: bool = False):
|
|||||||
|
|
||||||
async def _run():
|
async def _run():
|
||||||
active_scene = await ss.active_scene()
|
active_scene = await ss.active_scene()
|
||||||
click.echo(
|
console.out.print(
|
||||||
f'Current active scene: {click.style(active_scene.name, fg="green")} '
|
f'Current active scene: {console.highlight(ctx, active_scene.name)} '
|
||||||
f'{f"(ID: {active_scene.id})" if id else ""}'
|
f'{f"(ID: {console.highlight(ctx, active_scene.id)})" if id else ""}'
|
||||||
)
|
)
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
async with create_task_group() as tg:
|
try:
|
||||||
tg.start_soon(conn.background_processing)
|
async with create_task_group() as tg:
|
||||||
tg.start_soon(_run)
|
tg.start_soon(conn.background_processing)
|
||||||
|
tg.start_soon(_run)
|
||||||
|
except* ProtocolError as excgroup:
|
||||||
|
p_error = next(iter(excgroup.exceptions))
|
||||||
|
raisable = SlobsCliProtocolError(str(p_error))
|
||||||
|
raise raisable
|
||||||
|
|
||||||
|
|
||||||
@scene.command()
|
@scene.command()
|
||||||
@@ -108,18 +131,21 @@ async def switch(
|
|||||||
if model.studio_mode:
|
if model.studio_mode:
|
||||||
await ss.make_scene_active(scene.id)
|
await ss.make_scene_active(scene.id)
|
||||||
if preview:
|
if preview:
|
||||||
click.echo(
|
console.out.print(
|
||||||
f'Switched to preview scene: {click.style(scene.name, fg="blue")} '
|
f'Switched to preview scene: {console.highlight(ctx, scene.name)} '
|
||||||
f'{f"(ID: {scene.id})." if id else ""}'
|
f'{f"(ID: {console.highlight(ctx, scene.id)})" if id else ""}'
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
click.echo(
|
console.out.print(
|
||||||
f'Switched to scene: {click.style(scene.name, fg="blue")} '
|
f'Switched to scene: {console.highlight(ctx, scene.name)} '
|
||||||
f'{f"(ID: {scene.id})." if id else ""}'
|
f'{f"(ID: {console.highlight(ctx, scene.id)})" if id else ""}'
|
||||||
)
|
)
|
||||||
await ts.execute_studio_mode_transition()
|
console.err.print(
|
||||||
click.echo(
|
console.warning(
|
||||||
'Executed studio mode transition to make the scene active.'
|
ctx,
|
||||||
|
'Warning: You are in studio mode. The scene switch is not active yet.\n'
|
||||||
|
'use `slobs-cli studiomode force-transition` to activate the scene switch.',
|
||||||
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if preview:
|
if preview:
|
||||||
@@ -129,21 +155,25 @@ async def switch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
await ss.make_scene_active(scene.id)
|
await ss.make_scene_active(scene.id)
|
||||||
click.echo(
|
console.out.print(
|
||||||
f'Switched to scene: {click.style(scene.name, fg="blue")} '
|
f'Switched to scene: {console.highlight(ctx, scene.name)} '
|
||||||
f'{f"(ID: {scene.id})." if id else ""}'
|
f'{f"(ID: {console.highlight(ctx, scene.id)})" if id else ""}'
|
||||||
)
|
)
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
break
|
break
|
||||||
else: # If no scene by the given name was found
|
else: # If no scene by the given name was found
|
||||||
conn.close()
|
conn.close()
|
||||||
raise SlobsCliError(f"Scene '{scene_name}' not found.")
|
raise SlobsCliError(f'Scene "{scene_name}" not found.')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with create_task_group() as tg:
|
async with create_task_group() as tg:
|
||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
tg.start_soon(_run)
|
tg.start_soon(_run)
|
||||||
except* SlobsCliError as excgroup:
|
except* SlobsCliError as excgroup:
|
||||||
for e in excgroup.exceptions:
|
raisable = next(iter(excgroup.exceptions))
|
||||||
raise e
|
raise raisable
|
||||||
|
except* ProtocolError as excgroup:
|
||||||
|
p_error = next(iter(excgroup.exceptions))
|
||||||
|
raisable = SlobsCliProtocolError(str(p_error))
|
||||||
|
raise raisable
|
||||||
|
|||||||
@@ -3,8 +3,10 @@
|
|||||||
import asyncclick as click
|
import asyncclick as click
|
||||||
from anyio import create_task_group
|
from anyio import create_task_group
|
||||||
from pyslobs import ISceneCollectionCreateOptions, SceneCollectionsService
|
from pyslobs import ISceneCollectionCreateOptions, SceneCollectionsService
|
||||||
from terminaltables3 import AsciiTable
|
from rich.table import Table
|
||||||
|
from rich.text import Text
|
||||||
|
|
||||||
|
from . import console, util
|
||||||
from .cli import cli
|
from .cli import cli
|
||||||
from .errors import SlobsCliError
|
from .errors import SlobsCliError
|
||||||
|
|
||||||
@@ -25,35 +27,46 @@ async def list(ctx: click.Context, id: bool):
|
|||||||
async def _run():
|
async def _run():
|
||||||
collections = await scs.collections()
|
collections = await scs.collections()
|
||||||
if not collections:
|
if not collections:
|
||||||
click.echo('No scene collections found.')
|
console.out.print('No scene collections found.')
|
||||||
conn.close()
|
conn.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
active_collection = await scs.active_collection()
|
active_collection = await scs.active_collection()
|
||||||
|
|
||||||
table_data = [
|
style = ctx.obj['style']
|
||||||
['Scene Collection Name', 'ID', 'Active']
|
table = Table(
|
||||||
if id
|
show_header=True,
|
||||||
else ['Scene Collection Name', 'Active']
|
header_style=style.header,
|
||||||
]
|
border_style=style.border,
|
||||||
for collection in collections:
|
)
|
||||||
if collection.id == active_collection.id:
|
|
||||||
to_append = [click.style(collection.name, fg='green')]
|
|
||||||
else:
|
|
||||||
to_append = [click.style(collection.name, fg='blue')]
|
|
||||||
if id:
|
|
||||||
to_append.append(collection.id)
|
|
||||||
if collection.id == active_collection.id:
|
|
||||||
to_append.append('✅')
|
|
||||||
table_data.append(to_append)
|
|
||||||
|
|
||||||
table = AsciiTable(table_data)
|
if id:
|
||||||
table.justify_columns = {
|
columns = [
|
||||||
0: 'left',
|
('Scene Collection Name', 'left'),
|
||||||
1: 'left' if id else 'center',
|
('Active', 'center'),
|
||||||
2: 'center' if id else None,
|
('ID', 'left'),
|
||||||
}
|
]
|
||||||
click.echo(table.table)
|
else:
|
||||||
|
columns = [
|
||||||
|
('Scene Collection Name', 'left'),
|
||||||
|
('Active', 'center'),
|
||||||
|
]
|
||||||
|
|
||||||
|
for heading, justify in columns:
|
||||||
|
table.add_column(Text(heading, justify='center'), justify=justify)
|
||||||
|
|
||||||
|
for collection in collections:
|
||||||
|
to_append = [Text(collection.name, style=style.cell)]
|
||||||
|
to_append.append(
|
||||||
|
util.check_mark(
|
||||||
|
ctx, collection.id == active_collection.id, empty_if_false=True
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if id:
|
||||||
|
to_append.append(Text(collection.id, style=style.cell))
|
||||||
|
table.add_row(*to_append)
|
||||||
|
|
||||||
|
console.out.print(table)
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
@@ -80,7 +93,9 @@ async def load(ctx: click.Context, scenecollection_name: str):
|
|||||||
raise SlobsCliError(f'Scene collection "{scenecollection_name}" not found.')
|
raise SlobsCliError(f'Scene collection "{scenecollection_name}" not found.')
|
||||||
|
|
||||||
await scs.load(collection.id)
|
await scs.load(collection.id)
|
||||||
click.echo(f'Scene collection "{scenecollection_name}" loaded successfully.')
|
console.out.print(
|
||||||
|
f'Scene collection {console.highlight(scenecollection_name)} loaded successfully.'
|
||||||
|
)
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -88,8 +103,8 @@ async def load(ctx: click.Context, scenecollection_name: str):
|
|||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
tg.start_soon(_run)
|
tg.start_soon(_run)
|
||||||
except* SlobsCliError as excgroup:
|
except* SlobsCliError as excgroup:
|
||||||
for e in excgroup.exceptions:
|
raisable = next(iter(excgroup.exceptions))
|
||||||
raise e
|
raise raisable
|
||||||
|
|
||||||
|
|
||||||
@scenecollection.command()
|
@scenecollection.command()
|
||||||
@@ -102,7 +117,9 @@ async def create(ctx: click.Context, scenecollection_name: str):
|
|||||||
|
|
||||||
async def _run():
|
async def _run():
|
||||||
await scs.create(ISceneCollectionCreateOptions(scenecollection_name))
|
await scs.create(ISceneCollectionCreateOptions(scenecollection_name))
|
||||||
click.echo(f'Scene collection "{scenecollection_name}" created successfully.')
|
console.out.print(
|
||||||
|
f'Scene collection {console.highlight(scenecollection_name)} created successfully.'
|
||||||
|
)
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
async with create_task_group() as tg:
|
async with create_task_group() as tg:
|
||||||
@@ -128,7 +145,9 @@ async def delete(ctx: click.Context, scenecollection_name: str):
|
|||||||
raise SlobsCliError(f'Scene collection "{scenecollection_name}" not found.')
|
raise SlobsCliError(f'Scene collection "{scenecollection_name}" not found.')
|
||||||
|
|
||||||
await scs.delete(collection.id)
|
await scs.delete(collection.id)
|
||||||
click.echo(f'Scene collection "{scenecollection_name}" deleted successfully.')
|
console.out.print(
|
||||||
|
f'Scene collection {console.highlight(scenecollection_name)} deleted successfully.'
|
||||||
|
)
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -136,8 +155,8 @@ async def delete(ctx: click.Context, scenecollection_name: str):
|
|||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
tg.start_soon(_run)
|
tg.start_soon(_run)
|
||||||
except* SlobsCliError as excgroup:
|
except* SlobsCliError as excgroup:
|
||||||
for e in excgroup.exceptions:
|
raisable = next(iter(excgroup.exceptions))
|
||||||
raise e
|
raise raisable
|
||||||
|
|
||||||
|
|
||||||
@scenecollection.command()
|
@scenecollection.command()
|
||||||
@@ -159,8 +178,8 @@ async def rename(ctx: click.Context, scenecollection_name: str, new_name: str):
|
|||||||
raise SlobsCliError(f'Scene collection "{scenecollection_name}" not found.')
|
raise SlobsCliError(f'Scene collection "{scenecollection_name}" not found.')
|
||||||
|
|
||||||
await scs.rename(new_name, collection.id)
|
await scs.rename(new_name, collection.id)
|
||||||
click.echo(
|
console.out.print(
|
||||||
f'Scene collection "{scenecollection_name}" renamed to "{new_name}".'
|
f'Scene collection {console.highlight(scenecollection_name)} renamed to {console.highlight(new_name)}.'
|
||||||
)
|
)
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
@@ -169,5 +188,5 @@ async def rename(ctx: click.Context, scenecollection_name: str, new_name: str):
|
|||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
tg.start_soon(_run)
|
tg.start_soon(_run)
|
||||||
except* SlobsCliError as excgroup:
|
except* SlobsCliError as excgroup:
|
||||||
for e in excgroup.exceptions:
|
raisable = next(iter(excgroup.exceptions))
|
||||||
raise e
|
raise raisable
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import asyncclick as click
|
|||||||
from anyio import create_task_group
|
from anyio import create_task_group
|
||||||
from pyslobs import StreamingService
|
from pyslobs import StreamingService
|
||||||
|
|
||||||
|
from . import console
|
||||||
from .cli import cli
|
from .cli import cli
|
||||||
from .errors import SlobsCliError
|
from .errors import SlobsCliError
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ async def start(ctx: click.Context):
|
|||||||
raise SlobsCliError('Stream is already active.')
|
raise SlobsCliError('Stream is already active.')
|
||||||
|
|
||||||
await ss.toggle_streaming()
|
await ss.toggle_streaming()
|
||||||
click.echo('Stream started.')
|
console.out.print('Stream started.')
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -37,8 +38,8 @@ async def start(ctx: click.Context):
|
|||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
tg.start_soon(_run)
|
tg.start_soon(_run)
|
||||||
except* SlobsCliError as excgroup:
|
except* SlobsCliError as excgroup:
|
||||||
for e in excgroup.exceptions:
|
raisable = next(iter(excgroup.exceptions))
|
||||||
raise e
|
raise raisable
|
||||||
|
|
||||||
|
|
||||||
@stream.command()
|
@stream.command()
|
||||||
@@ -57,7 +58,7 @@ async def stop(ctx: click.Context):
|
|||||||
raise SlobsCliError('Stream is already inactive.')
|
raise SlobsCliError('Stream is already inactive.')
|
||||||
|
|
||||||
await ss.toggle_streaming()
|
await ss.toggle_streaming()
|
||||||
click.echo('Stream stopped.')
|
console.out.print('Stream stopped.')
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -65,8 +66,8 @@ async def stop(ctx: click.Context):
|
|||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
tg.start_soon(_run)
|
tg.start_soon(_run)
|
||||||
except* SlobsCliError as excgroup:
|
except* SlobsCliError as excgroup:
|
||||||
for e in excgroup.exceptions:
|
raisable = next(iter(excgroup.exceptions))
|
||||||
raise e
|
raise raisable
|
||||||
|
|
||||||
|
|
||||||
@stream.command()
|
@stream.command()
|
||||||
@@ -81,9 +82,9 @@ async def status(ctx: click.Context):
|
|||||||
active = model.streaming_status != 'offline'
|
active = model.streaming_status != 'offline'
|
||||||
|
|
||||||
if active:
|
if active:
|
||||||
click.echo('Stream is currently active.')
|
console.out.print('Stream is currently active.')
|
||||||
else:
|
else:
|
||||||
click.echo('Stream is currently inactive.')
|
console.out.print('Stream is currently inactive.')
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
async with create_task_group() as tg:
|
async with create_task_group() as tg:
|
||||||
@@ -104,9 +105,9 @@ async def toggle(ctx: click.Context):
|
|||||||
|
|
||||||
await ss.toggle_streaming()
|
await ss.toggle_streaming()
|
||||||
if active:
|
if active:
|
||||||
click.echo('Stream stopped.')
|
console.out.print('Stream stopped.')
|
||||||
else:
|
else:
|
||||||
click.echo('Stream started.')
|
console.out.print('Stream started.')
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import asyncclick as click
|
|||||||
from anyio import create_task_group
|
from anyio import create_task_group
|
||||||
from pyslobs import TransitionsService
|
from pyslobs import TransitionsService
|
||||||
|
|
||||||
|
from . import console
|
||||||
from .cli import cli
|
from .cli import cli
|
||||||
from .errors import SlobsCliError
|
from .errors import SlobsCliError
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ async def enable(ctx: click.Context):
|
|||||||
raise SlobsCliError('Studio mode is already enabled.')
|
raise SlobsCliError('Studio mode is already enabled.')
|
||||||
|
|
||||||
await ts.enable_studio_mode()
|
await ts.enable_studio_mode()
|
||||||
click.echo('Studio mode enabled successfully.')
|
console.out.print('Studio mode enabled successfully.')
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -35,8 +36,8 @@ async def enable(ctx: click.Context):
|
|||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
tg.start_soon(_run)
|
tg.start_soon(_run)
|
||||||
except* SlobsCliError as excgroup:
|
except* SlobsCliError as excgroup:
|
||||||
for e in excgroup.exceptions:
|
raisable = next(iter(excgroup.exceptions))
|
||||||
raise e
|
raise raisable
|
||||||
|
|
||||||
|
|
||||||
@studiomode.command()
|
@studiomode.command()
|
||||||
@@ -53,7 +54,7 @@ async def disable(ctx: click.Context):
|
|||||||
raise SlobsCliError('Studio mode is already disabled.')
|
raise SlobsCliError('Studio mode is already disabled.')
|
||||||
|
|
||||||
await ts.disable_studio_mode()
|
await ts.disable_studio_mode()
|
||||||
click.echo('Studio mode disabled successfully.')
|
console.out.print('Studio mode disabled successfully.')
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -61,8 +62,8 @@ async def disable(ctx: click.Context):
|
|||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
tg.start_soon(_run)
|
tg.start_soon(_run)
|
||||||
except* SlobsCliError as excgroup:
|
except* SlobsCliError as excgroup:
|
||||||
for e in excgroup.exceptions:
|
raisable = next(iter(excgroup.exceptions))
|
||||||
raise e
|
raise raisable
|
||||||
|
|
||||||
|
|
||||||
@studiomode.command()
|
@studiomode.command()
|
||||||
@@ -75,9 +76,9 @@ async def status(ctx: click.Context):
|
|||||||
async def _run():
|
async def _run():
|
||||||
model = await ts.get_model()
|
model = await ts.get_model()
|
||||||
if model.studio_mode:
|
if model.studio_mode:
|
||||||
click.echo('Studio mode is currently enabled.')
|
console.out.print('Studio mode is currently enabled.')
|
||||||
else:
|
else:
|
||||||
click.echo('Studio mode is currently disabled.')
|
console.out.print('Studio mode is currently disabled.')
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
async with create_task_group() as tg:
|
async with create_task_group() as tg:
|
||||||
@@ -96,10 +97,10 @@ async def toggle(ctx: click.Context):
|
|||||||
model = await ts.get_model()
|
model = await ts.get_model()
|
||||||
if model.studio_mode:
|
if model.studio_mode:
|
||||||
await ts.disable_studio_mode()
|
await ts.disable_studio_mode()
|
||||||
click.echo('Studio mode disabled successfully.')
|
console.out.print('Studio mode disabled successfully.')
|
||||||
else:
|
else:
|
||||||
await ts.enable_studio_mode()
|
await ts.enable_studio_mode()
|
||||||
click.echo('Studio mode enabled successfully.')
|
console.out.print('Studio mode enabled successfully.')
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
async with create_task_group() as tg:
|
async with create_task_group() as tg:
|
||||||
@@ -121,7 +122,7 @@ async def force_transition(ctx: click.Context):
|
|||||||
raise SlobsCliError('Studio mode is not enabled.')
|
raise SlobsCliError('Studio mode is not enabled.')
|
||||||
|
|
||||||
await ts.execute_studio_mode_transition()
|
await ts.execute_studio_mode_transition()
|
||||||
click.echo('Forced studio mode transition.')
|
console.out.print('Forced studio mode transition.')
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -129,5 +130,5 @@ async def force_transition(ctx: click.Context):
|
|||||||
tg.start_soon(conn.background_processing)
|
tg.start_soon(conn.background_processing)
|
||||||
tg.start_soon(_run)
|
tg.start_soon(_run)
|
||||||
except* SlobsCliError as excgroup:
|
except* SlobsCliError as excgroup:
|
||||||
for e in excgroup.exceptions:
|
raisable = next(iter(excgroup.exceptions))
|
||||||
raise e
|
raise raisable
|
||||||
|
|||||||
211
src/slobs_cli/styles.py
Normal file
211
src/slobs_cli/styles.py
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
"""module containing style management for Slobs CLI."""
|
||||||
|
|
||||||
|
import os
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
registry = {}
|
||||||
|
|
||||||
|
|
||||||
|
def register_style(cls):
|
||||||
|
"""Register a style class."""
|
||||||
|
key = cls.__name__.lower()
|
||||||
|
if key in registry:
|
||||||
|
raise ValueError(f'Style {key} is already registered.')
|
||||||
|
registry[key] = cls
|
||||||
|
return cls
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Style:
|
||||||
|
"""Base class for styles."""
|
||||||
|
|
||||||
|
name: str
|
||||||
|
border: str
|
||||||
|
header: str
|
||||||
|
cell: str
|
||||||
|
highlight: str
|
||||||
|
warning: str
|
||||||
|
no_border: bool = False
|
||||||
|
|
||||||
|
def __post_init__(self):
|
||||||
|
"""Post-initialization to set default values and normalize the name."""
|
||||||
|
self.name = self.name.lower()
|
||||||
|
if self.no_border:
|
||||||
|
self.border = None
|
||||||
|
|
||||||
|
|
||||||
|
@register_style
|
||||||
|
@dataclass
|
||||||
|
class Disabled(Style):
|
||||||
|
"""Disabled style."""
|
||||||
|
|
||||||
|
name: str = 'disabled'
|
||||||
|
header: str = ''
|
||||||
|
border: str = 'none'
|
||||||
|
cell: str = 'none'
|
||||||
|
highlight: str = 'none'
|
||||||
|
warning: str = 'none'
|
||||||
|
|
||||||
|
|
||||||
|
@register_style
|
||||||
|
@dataclass
|
||||||
|
class Red(Style):
|
||||||
|
"""Red style."""
|
||||||
|
|
||||||
|
name: str = 'red'
|
||||||
|
header: str = ''
|
||||||
|
border: str = 'dark_red'
|
||||||
|
cell: str = 'red'
|
||||||
|
highlight: str = 'red3'
|
||||||
|
warning: str = 'magenta'
|
||||||
|
|
||||||
|
|
||||||
|
@register_style
|
||||||
|
@dataclass
|
||||||
|
class Magenta(Style):
|
||||||
|
"""Magenta style."""
|
||||||
|
|
||||||
|
name: str = 'magenta'
|
||||||
|
header: str = ''
|
||||||
|
border: str = 'dark_magenta'
|
||||||
|
cell: str = 'magenta'
|
||||||
|
highlight: str = 'magenta3'
|
||||||
|
warning: str = 'magenta'
|
||||||
|
|
||||||
|
|
||||||
|
@register_style
|
||||||
|
@dataclass
|
||||||
|
class Purple(Style):
|
||||||
|
"""Purple style."""
|
||||||
|
|
||||||
|
name: str = 'purple'
|
||||||
|
header: str = ''
|
||||||
|
border: str = 'purple'
|
||||||
|
cell: str = 'medium_orchid'
|
||||||
|
highlight: str = 'medium_orchid'
|
||||||
|
warning: str = 'magenta'
|
||||||
|
|
||||||
|
|
||||||
|
@register_style
|
||||||
|
@dataclass
|
||||||
|
class Blue(Style):
|
||||||
|
"""Blue style."""
|
||||||
|
|
||||||
|
name: str = 'blue'
|
||||||
|
header: str = ''
|
||||||
|
border: str = 'dark_blue'
|
||||||
|
cell: str = 'blue'
|
||||||
|
highlight: str = 'blue3'
|
||||||
|
warning: str = 'magenta'
|
||||||
|
|
||||||
|
|
||||||
|
@register_style
|
||||||
|
@dataclass
|
||||||
|
class Cyan(Style):
|
||||||
|
"""Cyan style."""
|
||||||
|
|
||||||
|
name: str = 'cyan'
|
||||||
|
header: str = ''
|
||||||
|
border: str = 'dark_cyan'
|
||||||
|
cell: str = 'cyan'
|
||||||
|
highlight: str = 'cyan3'
|
||||||
|
warning: str = 'magenta'
|
||||||
|
|
||||||
|
|
||||||
|
@register_style
|
||||||
|
@dataclass
|
||||||
|
class Green(Style):
|
||||||
|
"""Green style."""
|
||||||
|
|
||||||
|
name: str = 'green'
|
||||||
|
header: str = ''
|
||||||
|
border: str = 'dark_green'
|
||||||
|
cell: str = 'green'
|
||||||
|
highlight: str = 'green3'
|
||||||
|
warning: str = 'magenta'
|
||||||
|
|
||||||
|
|
||||||
|
@register_style
|
||||||
|
@dataclass
|
||||||
|
class Yellow(Style):
|
||||||
|
"""Yellow style."""
|
||||||
|
|
||||||
|
name: str = 'yellow'
|
||||||
|
header: str = ''
|
||||||
|
border: str = 'yellow3'
|
||||||
|
cell: str = 'wheat1'
|
||||||
|
highlight: str = 'yellow3'
|
||||||
|
warning: str = 'magenta'
|
||||||
|
|
||||||
|
|
||||||
|
@register_style
|
||||||
|
@dataclass
|
||||||
|
class Orange(Style):
|
||||||
|
"""Orange style."""
|
||||||
|
|
||||||
|
name: str = 'orange'
|
||||||
|
header: str = ''
|
||||||
|
border: str = 'dark_orange'
|
||||||
|
cell: str = 'orange'
|
||||||
|
highlight: str = 'orange3'
|
||||||
|
warning: str = 'magenta'
|
||||||
|
|
||||||
|
|
||||||
|
@register_style
|
||||||
|
@dataclass
|
||||||
|
class White(Style):
|
||||||
|
"""White style."""
|
||||||
|
|
||||||
|
name: str = 'white'
|
||||||
|
header: str = ''
|
||||||
|
border: str = 'white'
|
||||||
|
cell: str = 'white'
|
||||||
|
highlight: str = 'white'
|
||||||
|
warning: str = 'magenta'
|
||||||
|
|
||||||
|
|
||||||
|
@register_style
|
||||||
|
@dataclass
|
||||||
|
class Grey(Style):
|
||||||
|
"""Grey style."""
|
||||||
|
|
||||||
|
name: str = 'grey'
|
||||||
|
header: str = ''
|
||||||
|
border: str = 'grey50'
|
||||||
|
cell: str = 'grey70'
|
||||||
|
highlight: str = 'grey90'
|
||||||
|
warning: str = 'magenta'
|
||||||
|
|
||||||
|
|
||||||
|
@register_style
|
||||||
|
@dataclass
|
||||||
|
class Navy(Style):
|
||||||
|
"""Navy style."""
|
||||||
|
|
||||||
|
name: str = 'navy'
|
||||||
|
header: str = ''
|
||||||
|
border: str = 'deep_sky_blue4'
|
||||||
|
cell: str = 'light_sky_blue3'
|
||||||
|
highlight: str = 'light_sky_blue3'
|
||||||
|
warning: str = 'magenta'
|
||||||
|
|
||||||
|
|
||||||
|
@register_style
|
||||||
|
@dataclass
|
||||||
|
class Black(Style):
|
||||||
|
"""Black style."""
|
||||||
|
|
||||||
|
name: str = 'black'
|
||||||
|
header: str = ''
|
||||||
|
border: str = 'black'
|
||||||
|
cell: str = 'grey30'
|
||||||
|
highlight: str = 'grey30'
|
||||||
|
warning: str = 'magenta'
|
||||||
|
|
||||||
|
|
||||||
|
def request_style_obj(style_name: str, no_border: bool) -> Style:
|
||||||
|
"""Request a style object by name."""
|
||||||
|
if style_name == 'disabled':
|
||||||
|
os.environ['NO_COLOR'] = '1'
|
||||||
|
|
||||||
|
return registry[style_name.lower()](no_border=no_border)
|
||||||
19
src/slobs_cli/util.py
Normal file
19
src/slobs_cli/util.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
"""module containing utility functions for Slobs CLI."""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
import asyncclick as click
|
||||||
|
|
||||||
|
|
||||||
|
def check_mark(ctx: click.Context, value: bool, empty_if_false: bool = False) -> str:
|
||||||
|
"""Return a check mark or cross mark based on the boolean value."""
|
||||||
|
if empty_if_false and not value:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
# rich gracefully handles the absence of colour throughout the rest of the application,
|
||||||
|
# but here we must handle it manually.
|
||||||
|
# If NO_COLOR is set, we return plain text symbols.
|
||||||
|
# Otherwise, we return coloured symbols.
|
||||||
|
if os.getenv('NO_COLOR', '') != '':
|
||||||
|
return '✓' if value else '✗'
|
||||||
|
return '✅' if value else '❌'
|
||||||
@@ -9,7 +9,13 @@ import os
|
|||||||
|
|
||||||
import anyio
|
import anyio
|
||||||
from anyio import create_task_group
|
from anyio import create_task_group
|
||||||
from pyslobs import ConnectionConfig, ScenesService, SlobsConnection, StreamingService
|
from pyslobs import (
|
||||||
|
ConnectionConfig,
|
||||||
|
ScenesService,
|
||||||
|
SlobsConnection,
|
||||||
|
StreamingService,
|
||||||
|
TransitionsService,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def cleanup(conn: SlobsConnection):
|
async def cleanup(conn: SlobsConnection):
|
||||||
@@ -29,6 +35,11 @@ async def cleanup(conn: SlobsConnection):
|
|||||||
if model.recording_status != 'offline':
|
if model.recording_status != 'offline':
|
||||||
await ss.toggle_recording()
|
await ss.toggle_recording()
|
||||||
|
|
||||||
|
ts = TransitionsService(conn)
|
||||||
|
model = await ts.get_model()
|
||||||
|
if model.studio_mode:
|
||||||
|
await ts.disable_studio_mode()
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
"""Test cases for scene commands in slobs_cli."""
|
"""Test cases for scene commands in slobs_cli."""
|
||||||
|
|
||||||
|
import anyio
|
||||||
import pytest
|
import pytest
|
||||||
from asyncclick.testing import CliRunner
|
from asyncclick.testing import CliRunner
|
||||||
|
|
||||||
@@ -15,6 +16,7 @@ async def test_scene_list():
|
|||||||
assert 'slobs-test-scene-1' in result.output
|
assert 'slobs-test-scene-1' in result.output
|
||||||
assert 'slobs-test-scene-2' in result.output
|
assert 'slobs-test-scene-2' in result.output
|
||||||
assert 'slobs-test-scene-3' in result.output
|
assert 'slobs-test-scene-3' in result.output
|
||||||
|
await anyio.sleep(0.2) # Avoid rate limiting issues
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
@@ -23,7 +25,19 @@ async def test_scene_current():
|
|||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
result = await runner.invoke(cli, ['scene', 'switch', 'slobs-test-scene-2'])
|
result = await runner.invoke(cli, ['scene', 'switch', 'slobs-test-scene-2'])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
await anyio.sleep(0.2) # Avoid rate limiting issues
|
||||||
|
|
||||||
result = await runner.invoke(cli, ['scene', 'current'])
|
result = await runner.invoke(cli, ['scene', 'current'])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert 'Current active scene: slobs-test-scene-2' in result.output
|
assert 'Current active scene: slobs-test-scene-2' in result.output
|
||||||
|
await anyio.sleep(0.2) # Avoid rate limiting issues
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.anyio
|
||||||
|
async def test_scene_invalid_switch():
|
||||||
|
"""Test switching to an invalid scene."""
|
||||||
|
runner = CliRunner()
|
||||||
|
result = await runner.invoke(cli, ['scene', 'switch', 'invalid-scene'])
|
||||||
|
assert result.exit_code != 0
|
||||||
|
assert 'Scene "invalid-scene" not found' in result.output
|
||||||
|
await anyio.sleep(0.2) # Avoid rate limiting issues
|
||||||
|
|||||||
Reference in New Issue
Block a user