///|
async fn main {
let command = @argparse.Command(
"moonatlas",
version="0.1.0",
about="Ecosystem-scale dependency intelligence for MoonBit packages.",
subcommand_required=true,
subcommands=[
@argparse.Command(
"analyze",
about="Analyze a Mooncakes snapshot.",
flags=[
@argparse.FlagArg(
"json",
about="Emit the complete machine-readable analysis.",
),
],
options=[
@argparse.OptionArg(
"output",
about="Write complete analysis JSON to this path.",
),
],
positionals=[
@argparse.PositionArg(
"snapshot",
about="Snapshot JSON path.",
num_args=@argparse.ValueRange::single(),
),
],
),
],
)
let matches = command.parse()
guard matches.subcommand is Some(("analyze", analyze_matches)) else {
abort("unreachable: argparse requires a subcommand")
}
guard analyze_matches.values.get("snapshot") is Some([snapshot_path]) else {
abort("unreachable: argparse requires a snapshot path")
}
let content = @fs.read_file(snapshot_path).text()
let snapshot = @snapshot.parse(content)
let result = @analysis.analyze(snapshot)
if analyze_matches.values.get("output") is Some([output_path]) {
@fs.write_file(output_path, @report.render_json(result))
println("Wrote MoonAtlas analysis to \{output_path}")
} else if analyze_matches.flags.get_or_default("json", false) {
println(@report.render_json(result))
} else {
println(@report.render_text(result))
}
}