|
| 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) |
0 commit comments