Skip to main content

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 and installs Codingest's code-review Agent Skill. The
5//! `CodeTreeCommand` variants are the 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;
13mod skill;
14mod skill_assets;
15
16use std::ffi::OsString;
17
18use anyhow::Result;
19use clap::Parser;
20
21#[derive(Parser, Debug)]
22#[command(name = "codingest", version, about)]
23struct Cli {
24    #[command(subcommand)]
25    command: code_tree_cli::CodeTreeCommand,
26}
27
28/// Run the CLI over an explicit argument vector, including the program name.
29///
30/// The standalone binary and the `pip install codingest` wheel shim both call
31/// this entry point, so command parsing and behavior cannot drift.
32pub fn run<I, T>(args: I) -> Result<()>
33where
34    I: IntoIterator<Item = T>,
35    T: Into<OsString> + Clone,
36{
37    let cli = Cli::parse_from(args);
38    code_tree_cli::run(&cli.command)
39}