codingest_cli/lib.rs
1//! Shared implementation of the `codingest` CLI.
2//!
3//! `codingest` builds/checks a `.kgl` code graph from a checkout or one or more
4//! git revisions. The `CodeTreeCommand` subcommands (Build / Status) are the
5//! binary's top-level commands.
6//!
7//! Pure-Rust over the sibling `codingest` builder + `kglite::api::io` (no
8//! libpython link in the standalone binary). The `pip install codingest` wheel
9//! links this same library through `_run_cli`, so command parsing and behavior
10//! cannot drift between the cargo binary and the console script.
11
12mod code_tree_cli;
13
14use std::ffi::OsString;
15
16use anyhow::Result;
17use clap::Parser;
18
19#[derive(Parser, Debug)]
20#[command(name = "codingest", version, about)]
21struct Cli {
22 #[command(subcommand)]
23 command: code_tree_cli::CodeTreeCommand,
24}
25
26/// Run the CLI over an explicit argument vector, including the program name.
27///
28/// The standalone binary and the `pip install codingest` wheel shim both call
29/// this entry point, so command parsing and behavior cannot drift.
30pub fn run<I, T>(args: I) -> Result<()>
31where
32 I: IntoIterator<Item = T>,
33 T: Into<OsString> + Clone,
34{
35 let cli = Cli::parse_from(args);
36 code_tree_cli::run(&cli.command)
37}