diff --git a/cli/src/castle_cli/commands/dev.py b/cli/src/castle_cli/commands/dev.py index 0093674..79e2e41 100644 --- a/cli/src/castle_cli/commands/dev.py +++ b/cli/src/castle_cli/commands/dev.py @@ -1,4 +1,4 @@ -"""castle test / castle lint - run dev commands across projects.""" +"""castle build / castle test / castle lint - run dev commands across projects.""" from __future__ import annotations @@ -98,3 +98,29 @@ def run_lint(args: argparse.Namespace) -> int: else: print("\nSome lint checks failed.") return 0 if all_passed else 1 + + +def run_build(args: argparse.Namespace) -> int: + """Run build for one or all projects.""" + config = load_config() + + if args.project: + success = _run_action(config, args.project, "build") + return 0 if success else 1 + + # Run all buildable projects + all_passed = True + for name, comp in config.programs.items(): + if not comp.source: + continue + handler = get_handler(comp.stack) + if handler is None: + continue + if not _run_action(config, name, "build"): + all_passed = False + + if all_passed: + print("\nAll builds succeeded.") + else: + print("\nSome builds failed.") + return 0 if all_passed else 1 diff --git a/cli/src/castle_cli/main.py b/cli/src/castle_cli/main.py index 390b633..9bd8545 100644 --- a/cli/src/castle_cli/main.py +++ b/cli/src/castle_cli/main.py @@ -55,6 +55,10 @@ def build_parser() -> argparse.ArgumentParser: lint_parser = subparsers.add_parser("lint", help="Run linter") lint_parser.add_argument("project", nargs="?", help="Project to lint (default: all)") + # castle build + build_parser = subparsers.add_parser("build", help="Build projects") + build_parser.add_argument("project", nargs="?", help="Project to build (default: all)") + # castle sync subparsers.add_parser("sync", help="Sync submodules and install dependencies") @@ -106,9 +110,7 @@ def build_parser() -> argparse.ArgumentParser: ) # castle deploy - deploy_parser = subparsers.add_parser( - "deploy", help="Deploy to ~/.castle/ (spec → runtime)" - ) + deploy_parser = subparsers.add_parser("deploy", help="Deploy to ~/.castle/ (spec → runtime)") deploy_parser.add_argument("name", nargs="?", help="Service or job to deploy (default: all)") # castle tool @@ -156,6 +158,11 @@ def main() -> int: return run_lint(args) + elif args.command == "build": + from castle_cli.commands.dev import run_build + + return run_build(args) + elif args.command == "sync": from castle_cli.commands.sync import run_sync