glas-harness/src/glas_harness/cli.py

47 lines
1.6 KiB
Python
Raw Normal View History

"""glas-harness CLI — thin wrapper around CLIChannel (GLAS-WP-0003)."""
from __future__ import annotations
import argparse
import sys
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(prog="glas-harness")
sub = parser.add_subparsers(dest="command", required=True)
run = sub.add_parser("run", help="Run one task through a rein inside a sand-boxer sandbox")
run.add_argument("--sandbox-profile", required=True, help="e.g. profile.bwrap-local")
run.add_argument("--repo", required=True, help="Local repo path to mirror into the sandbox")
run.add_argument("--title", required=True)
run.add_argument("--description", required=True)
run.add_argument("--actor", default="agt")
run.add_argument("--project", default="glas-harness")
run.add_argument("--no-hub", action="store_true", help="Skip the gateway's own hub reporting")
args = parser.parse_args(argv)
if args.command == "run":
from glas_harness.channels.cli_channel import CLIChannel
from glas_harness.gateway import run_task_through_rein
channel = CLIChannel()
invocation = channel.parse_invocation(args)
result = run_task_through_rein(
sandbox_profile=invocation.sandbox_profile,
repo=invocation.repo,
title=invocation.title,
description=invocation.description,
actor=invocation.actor,
project=invocation.project,
report_to_hub=invocation.report_to_hub,
)
print(channel.render_result(result))
return 0 if result["tool_ok"] else 1
return 1
if __name__ == "__main__":
sys.exit(main())