Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump typer from 0.12.5 to 0.13.0 #62

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 2 additions & 9 deletions src/alga/__main__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from rich import print
from typer import Typer

from alga import (
__version__,
cli_adhoc,
cli_app,
cli_channel,
Expand All @@ -12,6 +10,7 @@
cli_remote,
cli_setup,
cli_sound_output,
cli_version,
cli_volume,
)

Expand All @@ -30,13 +29,7 @@
# https://github.com/tiangolo/typer/issues/243
app.command()(cli_adhoc.adhoc)
app.command()(cli_setup.setup)


@app.command()
def version() -> None:
"""Print Alga version"""

print(f"alga version [bold]{__version__}[/bold]")
app.command()(cli_version.version)


if __name__ == "__main__":
Expand Down
28 changes: 14 additions & 14 deletions src/alga/cli_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
app = Typer(no_args_is_help=True, help="Apps installed on the TV")


@app.command()
def close(app_id: Annotated[str, Argument()]) -> None:
"""Close the provided app"""

client.request("ssap://system.launcher/close", {"id": app_id})


@app.command()
def current() -> None:
"""Get the current app"""
Expand All @@ -23,10 +30,14 @@ def current() -> None:


@app.command()
def close(app_id: Annotated[str, Argument()]) -> None:
"""Close the provided app"""
def info(app_id: str) -> None:
"""Show info about specific app"""

client.request("ssap://system.launcher/close", {"id": app_id})
response = client.request(
"ssap://com.webos.applicationManager/getAppInfo", {"id": app_id}
)

print(response["appInfo"])


@app.command()
Expand Down Expand Up @@ -61,14 +72,3 @@ def list() -> None:

console = Console()
console.print(table)


@app.command()
def info(app_id: str) -> None:
"""Show info about specific app"""

response = client.request(
"ssap://com.webos.applicationManager/getAppInfo", {"id": app_id}
)

print(response["appInfo"])
46 changes: 23 additions & 23 deletions src/alga/cli_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,13 @@ def current() -> None:
)


@app.command()
def up() -> None:
"""Change channel up"""

client.request("ssap://tv/channelUp")


@app.command()
def down() -> None:
"""Change channel down"""

client.request("ssap://tv/channelDown")


@app.command()
def set(value: Annotated[str, Argument()]) -> None:
"""Change to specific channel"""

if value.isnumeric():
# If a channel number is provided, we look up the channel ID as some models require it.
response = client.request("ssap://tv/getChannelList")

for channel in response["channelList"]:
if channel["channelNumber"] == value:
value = channel["channelId"]
break

client.request("ssap://tv/openChannel", {"channelId": value})


@app.command()
def list() -> None:
"""List available channels"""
Expand Down Expand Up @@ -80,3 +57,26 @@ def list() -> None:

console = Console()
console.print(table)


@app.command()
def set(value: Annotated[str, Argument()]) -> None:
"""Change to specific channel"""

if value.isnumeric():
# If a channel number is provided, we look up the channel ID as some models require it.
response = client.request("ssap://tv/getChannelList")

for channel in response["channelList"]:
if channel["channelNumber"] == value:
value = channel["channelId"]
break

client.request("ssap://tv/openChannel", {"channelId": value})


@app.command()
def up() -> None:
"""Change channel up"""

client.request("ssap://tv/channelUp")
14 changes: 7 additions & 7 deletions src/alga/cli_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
app = Typer(no_args_is_help=True, help="HDMI and similar inputs")


@app.command()
def set(value: Annotated[str, Argument()]) -> None:
"""Switch to given input"""

client.request("ssap://tv/switchInput", {"inputId": value})


@app.command()
def list() -> None:
"""List available inputs"""
Expand All @@ -36,3 +29,10 @@ def list() -> None:

console = Console()
console.print(table)


@app.command()
def set(value: Annotated[str, Argument()]) -> None:
"""Switch to given input"""

client.request("ssap://tv/switchInput", {"inputId": value})
24 changes: 12 additions & 12 deletions src/alga/cli_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@


@app.command()
def play() -> None:
"""Play media"""
def fast_forward() -> None:
"""Fast forward media"""

client.request("ssap://media.controls/play")
client.request("ssap://media.controls/fastForward")


@app.command()
Expand All @@ -21,21 +21,21 @@ def pause() -> None:


@app.command()
def stop() -> None:
"""Stop media"""
def play() -> None:
"""Play media"""

client.request("ssap://media.controls/stop")
client.request("ssap://media.controls/play")


@app.command()
def fast_forward() -> None:
"""Fast forward media"""
def rewind() -> None:
"""Rewind media"""

client.request("ssap://media.controls/fastForward")
client.request("ssap://media.controls/rewind")


@app.command()
def rewind() -> None:
"""Rewind media"""
def stop() -> None:
"""Stop media"""

client.request("ssap://media.controls/rewind")
client.request("ssap://media.controls/stop")
9 changes: 9 additions & 0 deletions src/alga/cli_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from rich import print

from alga import __version__


def version() -> None:
"""Print Alga version"""

print(f"alga version [bold]{__version__}[/bold]")
28 changes: 14 additions & 14 deletions src/alga/cli_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,13 @@
app = Typer(no_args_is_help=True, help="Audio volume")


@app.command()
def up() -> None:
"""Turn volume up"""

client.request("ssap://audio/volumeUp")


@app.command()
def down() -> None:
"""Turn volume down"""

client.request("ssap://audio/volumeDown")


@app.command()
def set(value: Annotated[int, Argument()]) -> None:
"""Set volume to specific amount"""

client.request("ssap://audio/setVolume", {"volume": value})


@app.command()
def get() -> None:
"""Get current volume"""
Expand All @@ -47,8 +33,22 @@ def mute() -> None:
client.request("ssap://audio/setMute", {"mute": True})


@app.command()
def set(value: Annotated[int, Argument()]) -> None:
"""Set volume to specific amount"""

client.request("ssap://audio/setVolume", {"volume": value})


@app.command()
def unmute() -> None:
"""Unmute audio"""

client.request("ssap://audio/setMute", {"mute": False})


@app.command()
def up() -> None:
"""Turn volume up"""

client.request("ssap://audio/volumeUp")
File renamed without changes.
68 changes: 34 additions & 34 deletions usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ $ alga [OPTIONS] COMMAND [ARGS]...
**Commands**:

* `adhoc`: Send raw request to the TV
* `setup`: Pair a new TV
* `version`: Print Alga version
* `app`: Apps installed on the TV
* `channel`: TV channels
* `input`: HDMI and similar inputs
* `media`: Control the playing media
* `power`: Turn TV (or screen) on and off
* `remote`: Remote control button presses
* `setup`: Pair a new TV
* `sound-output`: Audio output device
* `version`: Print Alga version
* `volume`: Audio volume

## `alga adhoc`
Expand All @@ -45,6 +45,38 @@ $ alga adhoc [OPTIONS] PATH [DATA]

* `--help`: Show this message and exit.

## `alga setup`

Pair a new TV

**Usage**:

```console
$ alga setup [OPTIONS] [HOSTNAME]
```

**Arguments**:

* `[HOSTNAME]`: [default: lgwebostv]

**Options**:

* `--help`: Show this message and exit.

## `alga version`

Print Alga version

**Usage**:

```console
$ alga version [OPTIONS]
```

**Options**:

* `--help`: Show this message and exit.

## `alga app`

Apps installed on the TV
Expand Down Expand Up @@ -502,24 +534,6 @@ $ alga remote send [OPTIONS] BUTTON

* `--help`: Show this message and exit.

## `alga setup`

Pair a new TV

**Usage**:

```console
$ alga setup [OPTIONS] [HOSTNAME]
```

**Arguments**:

* `[HOSTNAME]`: [default: lgwebostv]

**Options**:

* `--help`: Show this message and exit.

## `alga sound-output`

Audio output device
Expand Down Expand Up @@ -571,20 +585,6 @@ $ alga sound-output set [OPTIONS] VALUE

* `--help`: Show this message and exit.

## `alga version`

Print Alga version

**Usage**:

```console
$ alga version [OPTIONS]
```

**Options**:

* `--help`: Show this message and exit.

## `alga volume`

Audio volume
Expand Down