Skip to content

Commit

Permalink
Order the command definitions in alphabetical order
Browse files Browse the repository at this point in the history
This is to maintain the previous ordering - as much as possible - for now.

It's possible I want to revisit this in the future and order the commands in a
more logic manor, but for now I'll strive towards keeping the behaviour as it
was.
  • Loading branch information
Tenzer committed Nov 8, 2024
1 parent 99267fd commit f598965
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 104 deletions.
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")
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")
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

0 comments on commit f598965

Please sign in to comment.