Repository navigation
Expand file tree
/
Copy pathcli.py
More file actions
125 lines (108 loc) · 4.59 KB
/
Copy pathcli.py
File metadata and controls
125 lines (108 loc) · 4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
"""sourceosctl CLI entry point."""
import argparse
import sys
from sourceosctl import __version__
from sourceosctl.commands import (
doctor,
profiles,
nlboot,
release,
fingerprint,
ai,
agents,
)
def build_parser() -> argparse.ArgumentParser:
"""Build and return the argument parser."""
parser = argparse.ArgumentParser(
prog="sourceosctl",
description="SourceOS developer and AI operator CLI (read-only / dry-run surface)",
)
parser.add_argument(
"--version", action="version", version=f"sourceosctl {__version__}"
)
sub = parser.add_subparsers(dest="command", metavar="<command>")
sub.required = True
# --- doctor ---
doctor_p = sub.add_parser("doctor", help="Run environment health checks")
doctor_p.set_defaults(func=doctor.run)
# --- profiles ---
profiles_p = sub.add_parser("profiles", help="Profile management")
profiles_sub = profiles_p.add_subparsers(dest="profiles_command", metavar="<subcommand>")
profiles_sub.required = True
profiles_list_p = profiles_sub.add_parser("list", help="List available profiles")
profiles_list_p.set_defaults(func=profiles.list_profiles)
# --- nlboot ---
nlboot_p = sub.add_parser("nlboot", help="NLBoot operator helpers")
nlboot_sub = nlboot_p.add_subparsers(dest="nlboot_command", metavar="<subcommand>")
nlboot_sub.required = True
nlboot_evidence_p = nlboot_sub.add_parser("evidence", help="NLBoot evidence helpers")
nlboot_evidence_sub = nlboot_evidence_p.add_subparsers(
dest="nlboot_evidence_command", metavar="<subcommand>"
)
nlboot_evidence_sub.required = True
nlboot_inspect_p = nlboot_evidence_sub.add_parser(
"inspect", help="Inspect a NLBoot evidence file"
)
nlboot_inspect_p.add_argument("path", help="Path to NLBoot evidence JSON file")
nlboot_inspect_p.set_defaults(func=nlboot.inspect_evidence)
# --- release ---
release_p = sub.add_parser("release", help="Release artifact inspection")
release_sub = release_p.add_subparsers(dest="release_command", metavar="<subcommand>")
release_sub.required = True
release_inspect_p = release_sub.add_parser("inspect", help="Inspect a release artifact")
release_inspect_p.add_argument("path", help="Path to release artifact JSON file")
release_inspect_p.set_defaults(func=release.inspect)
# --- fingerprint ---
fingerprint_p = sub.add_parser("fingerprint", help="Environment fingerprint utilities")
fingerprint_sub = fingerprint_p.add_subparsers(
dest="fingerprint_command", metavar="<subcommand>"
)
fingerprint_sub.required = True
fingerprint_collect_p = fingerprint_sub.add_parser(
"collect", help="Collect environment fingerprint (dry-run only)"
)
fingerprint_collect_p.add_argument(
"--dry-run",
action="store_true",
default=True,
dest="dry_run",
help="Print what would be collected without writing to disk (default: True)",
)
fingerprint_collect_p.set_defaults(func=fingerprint.collect)
# --- ai ---
ai_p = sub.add_parser("ai", help="AI operator utilities")
ai_sub = ai_p.add_subparsers(dest="ai_command", metavar="<subcommand>")
ai_sub.required = True
ai_labs_p = ai_sub.add_parser("labs", help="AI lab helpers")
ai_labs_sub = ai_labs_p.add_subparsers(dest="ai_labs_command", metavar="<subcommand>")
ai_labs_sub.required = True
ai_labs_list_p = ai_labs_sub.add_parser("list", help="List available AI labs")
ai_labs_list_p.set_defaults(func=ai.list_labs)
# --- agents ---
agents_p = sub.add_parser("agents", help="Agent sandbox helpers")
agents_sub = agents_p.add_subparsers(dest="agents_command", metavar="<subcommand>")
agents_sub.required = True
agents_sandbox_p = agents_sub.add_parser("sandbox", help="Agent sandbox management")
agents_sandbox_sub = agents_sandbox_p.add_subparsers(
dest="agents_sandbox_command", metavar="<subcommand>"
)
agents_sandbox_sub.required = True
agents_sandbox_plan_p = agents_sandbox_sub.add_parser(
"plan", help="Plan agent sandbox (dry-run only)"
)
agents_sandbox_plan_p.add_argument(
"--dry-run",
action="store_true",
default=True,
dest="dry_run",
help="Print plan without executing (default: True)",
)
agents_sandbox_plan_p.set_defaults(func=agents.sandbox_plan)
return parser
def main(argv=None) -> int:
"""Main entry point. Returns exit code."""
parser = build_parser()
args = parser.parse_args(argv)
return args.func(args) or 0
if __name__ == "__main__":
sys.exit(main())