diff --git a/setup.py b/setup.py index 33e8bcb..a2598dd 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ setup( name="science-synapse", - version="2.3.4", + version="2.4.0", description="Client library and CLI for the Synapse API", author="Science Team", author_email="team@science.xyz", diff --git a/synapse/cli/__main__.py b/synapse/cli/__main__.py index 965f5a1..af66f34 100755 --- a/synapse/cli/__main__.py +++ b/synapse/cli/__main__.py @@ -9,8 +9,7 @@ from rich.logging import RichHandler from synapse.cli import ( - build, - deploy, + apps, discover, files, offline_plot, @@ -76,8 +75,7 @@ def main(): offline_plot.add_commands(subparsers) files.add_commands(subparsers) taps.add_commands(subparsers) - deploy.add_commands(subparsers) - build.add_commands(subparsers) + apps.add_commands(subparsers) settings.add_commands(subparsers) args = parser.parse_args() diff --git a/synapse/cli/apps.py b/synapse/cli/apps.py new file mode 100644 index 0000000..04b86b6 --- /dev/null +++ b/synapse/cli/apps.py @@ -0,0 +1,58 @@ +"""CLI commands for managing Synapse applications.""" + +from synapse.cli.build import build_cmd +from synapse.cli.deploy import deploy_cmd +from synapse.cli.rpc import list_apps + + +def add_commands(subparsers): + """Add the apps command group to the CLI.""" + apps_parser = subparsers.add_parser("apps", help="Manage applications on a Synapse device") + apps_subparsers = apps_parser.add_subparsers(title="App Commands") + + # build subcommand + build_parser = apps_subparsers.add_parser( + "build", + help="Cross-compile and package an application into a .deb without deploying", + ) + build_parser.add_argument( + "app_dir", + nargs="?", + default=".", + help="Path to the application directory (defaults to current working directory)", + ) + build_parser.add_argument( + "--skip-build", + action="store_true", + default=False, + help="Skip compilation phase; assume the binary already exists and only build the .deb package.", + ) + build_parser.add_argument( + "--clean", + action="store_true", + default=False, + help="Clean build directories and force a complete rebuild from scratch.", + ) + build_parser.set_defaults(func=build_cmd) + + # deploy subcommand + deploy_parser = apps_subparsers.add_parser( + "deploy", help="Deploy an application to a Synapse device" + ) + deploy_parser.add_argument( + "app_dir", nargs="?", default=".", help="Path to the application directory" + ) + deploy_parser.add_argument( + "--package", + "-p", + help="Path to a pre-built .deb to deploy (skips local build and package steps)", + type=str, + default=None, + ) + deploy_parser.set_defaults(func=deploy_cmd) + + # list subcommand + list_parser = apps_subparsers.add_parser( + "list", help="List installed applications on the device" + ) + list_parser.set_defaults(func=list_apps) diff --git a/synapse/cli/build.py b/synapse/cli/build.py index 00803db..a76fb8c 100644 --- a/synapse/cli/build.py +++ b/synapse/cli/build.py @@ -401,6 +401,8 @@ def build_deb_package(app_dir: str, app_name: str, version: str = "0.1.0") -> bo "Synapse Application", "--architecture", "arm64", + "--category", + "synapse-apps", ] # Attach lifecycle scripts @@ -542,31 +544,3 @@ def build_cmd(args) -> None: box=box.DOUBLE, ) ) - - -def add_commands(subparsers) -> None: - """Register the *build* command with the top-level CLI parser.""" - - build_parser = subparsers.add_parser( - "build", - help="Cross-compile and package an application into a .deb without deploying", - ) - build_parser.add_argument( - "app_dir", - nargs="?", - default=".", - help="Path to the application directory (defaults to current working directory)", - ) - build_parser.add_argument( - "--skip-build", - action="store_true", - default=False, - help="Skip compilation phase; assume the binary already exists and only build the .deb package.", - ) - build_parser.add_argument( - "--clean", - action="store_true", - default=False, - help="Clean build directories and force a complete rebuild from scratch.", - ) - build_parser.set_defaults(func=build_cmd) diff --git a/synapse/cli/deploy.py b/synapse/cli/deploy.py index 5614d22..2652557 100644 --- a/synapse/cli/deploy.py +++ b/synapse/cli/deploy.py @@ -260,21 +260,3 @@ def deploy_cmd(args): "[yellow]No URI provided. Package created but not deployed.[/yellow]" ) console.print(f"[green]Package available at:[/green] {deb_package}") - - -def add_commands(subparsers): - """Add deploy commands to the CLI""" - deploy_parser = subparsers.add_parser( - "deploy", help="Deploy an application to a Synapse device" - ) - deploy_parser.add_argument( - "app_dir", nargs="?", default=".", help="Path to the application directory" - ) - deploy_parser.add_argument( - "--package", - "-p", - help="Path to a pre-built .deb to deploy (skips local build and package steps)", - type=str, - default=None, - ) - deploy_parser.set_defaults(func=deploy_cmd) diff --git a/synapse/cli/rpc.py b/synapse/cli/rpc.py index 1191ed2..678e95b 100644 --- a/synapse/cli/rpc.py +++ b/synapse/cli/rpc.py @@ -97,9 +97,6 @@ def add_commands(subparsers): ) f.set_defaults(func=get_logs) - g = subparsers.add_parser("list-apps", help="List installed applications on the device") - g.set_defaults(func=list_apps) - def info(args): device = syn.Device(args.uri, args.verbose)