Skip to content

Commit b7b0b95

Browse files
authored
Add apps command group to CLI (#165)
* Add category flag to nfpm packaging Sets the package category to synapse-apps for better organization. * Add apps command group to CLI Reorganizes app-related commands under `synapsectl apps`: - synapsectl apps build - synapsectl apps deploy - synapsectl apps list Bumps version to 2.4.0.
1 parent ba69632 commit b7b0b95

6 files changed

Lines changed: 63 additions & 54 deletions

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
setup(
2828
name="science-synapse",
29-
version="2.3.4",
29+
version="2.4.0",
3030
description="Client library and CLI for the Synapse API",
3131
author="Science Team",
3232
author_email="team@science.xyz",

synapse/cli/__main__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
from rich.logging import RichHandler
1010

1111
from synapse.cli import (
12-
build,
13-
deploy,
12+
apps,
1413
discover,
1514
files,
1615
offline_plot,
@@ -76,8 +75,7 @@ def main():
7675
offline_plot.add_commands(subparsers)
7776
files.add_commands(subparsers)
7877
taps.add_commands(subparsers)
79-
deploy.add_commands(subparsers)
80-
build.add_commands(subparsers)
78+
apps.add_commands(subparsers)
8179
settings.add_commands(subparsers)
8280
args = parser.parse_args()
8381

synapse/cli/apps.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
"""CLI commands for managing Synapse applications."""
2+
3+
from synapse.cli.build import build_cmd
4+
from synapse.cli.deploy import deploy_cmd
5+
from synapse.cli.rpc import list_apps
6+
7+
8+
def add_commands(subparsers):
9+
"""Add the apps command group to the CLI."""
10+
apps_parser = subparsers.add_parser("apps", help="Manage applications on a Synapse device")
11+
apps_subparsers = apps_parser.add_subparsers(title="App Commands")
12+
13+
# build subcommand
14+
build_parser = apps_subparsers.add_parser(
15+
"build",
16+
help="Cross-compile and package an application into a .deb without deploying",
17+
)
18+
build_parser.add_argument(
19+
"app_dir",
20+
nargs="?",
21+
default=".",
22+
help="Path to the application directory (defaults to current working directory)",
23+
)
24+
build_parser.add_argument(
25+
"--skip-build",
26+
action="store_true",
27+
default=False,
28+
help="Skip compilation phase; assume the binary already exists and only build the .deb package.",
29+
)
30+
build_parser.add_argument(
31+
"--clean",
32+
action="store_true",
33+
default=False,
34+
help="Clean build directories and force a complete rebuild from scratch.",
35+
)
36+
build_parser.set_defaults(func=build_cmd)
37+
38+
# deploy subcommand
39+
deploy_parser = apps_subparsers.add_parser(
40+
"deploy", help="Deploy an application to a Synapse device"
41+
)
42+
deploy_parser.add_argument(
43+
"app_dir", nargs="?", default=".", help="Path to the application directory"
44+
)
45+
deploy_parser.add_argument(
46+
"--package",
47+
"-p",
48+
help="Path to a pre-built .deb to deploy (skips local build and package steps)",
49+
type=str,
50+
default=None,
51+
)
52+
deploy_parser.set_defaults(func=deploy_cmd)
53+
54+
# list subcommand
55+
list_parser = apps_subparsers.add_parser(
56+
"list", help="List installed applications on the device"
57+
)
58+
list_parser.set_defaults(func=list_apps)

synapse/cli/build.py

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,8 @@ def build_deb_package(app_dir: str, app_name: str, version: str = "0.1.0") -> bo
401401
"Synapse Application",
402402
"--architecture",
403403
"arm64",
404+
"--category",
405+
"synapse-apps",
404406
]
405407

406408
# Attach lifecycle scripts
@@ -542,31 +544,3 @@ def build_cmd(args) -> None:
542544
box=box.DOUBLE,
543545
)
544546
)
545-
546-
547-
def add_commands(subparsers) -> None:
548-
"""Register the *build* command with the top-level CLI parser."""
549-
550-
build_parser = subparsers.add_parser(
551-
"build",
552-
help="Cross-compile and package an application into a .deb without deploying",
553-
)
554-
build_parser.add_argument(
555-
"app_dir",
556-
nargs="?",
557-
default=".",
558-
help="Path to the application directory (defaults to current working directory)",
559-
)
560-
build_parser.add_argument(
561-
"--skip-build",
562-
action="store_true",
563-
default=False,
564-
help="Skip compilation phase; assume the binary already exists and only build the .deb package.",
565-
)
566-
build_parser.add_argument(
567-
"--clean",
568-
action="store_true",
569-
default=False,
570-
help="Clean build directories and force a complete rebuild from scratch.",
571-
)
572-
build_parser.set_defaults(func=build_cmd)

synapse/cli/deploy.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -260,21 +260,3 @@ def deploy_cmd(args):
260260
"[yellow]No URI provided. Package created but not deployed.[/yellow]"
261261
)
262262
console.print(f"[green]Package available at:[/green] {deb_package}")
263-
264-
265-
def add_commands(subparsers):
266-
"""Add deploy commands to the CLI"""
267-
deploy_parser = subparsers.add_parser(
268-
"deploy", help="Deploy an application to a Synapse device"
269-
)
270-
deploy_parser.add_argument(
271-
"app_dir", nargs="?", default=".", help="Path to the application directory"
272-
)
273-
deploy_parser.add_argument(
274-
"--package",
275-
"-p",
276-
help="Path to a pre-built .deb to deploy (skips local build and package steps)",
277-
type=str,
278-
default=None,
279-
)
280-
deploy_parser.set_defaults(func=deploy_cmd)

synapse/cli/rpc.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ def add_commands(subparsers):
9797
)
9898
f.set_defaults(func=get_logs)
9999

100-
g = subparsers.add_parser("list-apps", help="List installed applications on the device")
101-
g.set_defaults(func=list_apps)
102-
103100

104101
def info(args):
105102
device = syn.Device(args.uri, args.verbose)

0 commit comments

Comments
 (0)