Skip to content
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
48 changes: 48 additions & 0 deletions smpmgr/enumeration_management.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""The enum subcommand group."""

import asyncio
import logging
from typing import List, cast

import typer
from rich import print
from smpclient.requests.enumeration_management import GroupDetails, ListSupportedGroups
from typing_extensions import Annotated

from smpmgr.common import Options, connect_with_spinner, get_smpclient, smp_request

app = typer.Typer(name="enum", help="The SMP Enumeration Management Group.")
logger = logging.getLogger(__name__)


@app.command()
def get_supported_groups(ctx: typer.Context) -> None:
"""Request groups supported by the server."""

options = cast(Options, ctx.obj)
smpclient = get_smpclient(options)

async def f() -> None:
await connect_with_spinner(smpclient, options.timeout)
r = await smp_request(smpclient, options, ListSupportedGroups(), "Waiting for supported groups...") # type: ignore # noqa
print(r)

asyncio.run(f())


@app.command()
def get_group_details(
ctx: typer.Context,
groups: Annotated[List[int], typer.Argument(help="Groups to retrieve details for")],
) -> None:
"""Request groups supported by the server."""

options = cast(Options, ctx.obj)
smpclient = get_smpclient(options)

async def f() -> None:
await connect_with_spinner(smpclient, options.timeout)
r = await smp_request(smpclient, options, GroupDetails(groups=groups), "Waiting for group details...") # type: ignore # noqa
print(r)

asyncio.run(f())
5 changes: 3 additions & 2 deletions smpmgr/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from typing_extensions import Annotated, assert_never

from smpmgr import (
enumeration_management,
file_management,
image_management,
os_management,
Expand Down Expand Up @@ -68,6 +69,7 @@
app.add_typer(stat_management.app)
app.add_typer(image_management.app)
app.add_typer(file_management.app)
app.add_typer(enumeration_management.app)
app.add_typer(intercreate.app)
app.command()(shell_management.shell)
app.command()(terminal.terminal)
Expand All @@ -85,8 +87,7 @@ def options(
),
ble: str = typer.Option(None, help="The Bluetooth address to connect to"),
timeout: float = typer.Option(
2.0,
help="Transport timeout in seconds; how long to wait for initial connection and requests.",
2.0, help="Transport timeout in seconds; how long to wait for requests"
),
mtu: int
| None = typer.Option(
Expand Down