diff --git a/smpmgr/enumeration_management.py b/smpmgr/enumeration_management.py new file mode 100644 index 0000000..d826225 --- /dev/null +++ b/smpmgr/enumeration_management.py @@ -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()) diff --git a/smpmgr/main.py b/smpmgr/main.py index e0721e2..768cb05 100644 --- a/smpmgr/main.py +++ b/smpmgr/main.py @@ -19,6 +19,7 @@ from typing_extensions import Annotated, assert_never from smpmgr import ( + enumeration_management, file_management, image_management, os_management, @@ -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) @@ -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(