Skip to main content

coding_tools/cli/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Jonathan Shook
3
4//! CLI grammars for the leaf tools, hosted in the lib so each tool's clap
5//! definition is introspectable and reusable. Each `src/bin/<tool>.rs` entry
6//! point is a thin parse-and-dispatch wrapper over the `Cli` struct defined
7//! here; the schema-drift guard reconciles every `docs/explain/<tool>.json`
8//! against the live grammar these expose (see [`flags`]).
9
10use clap::CommandFactory;
11
12pub mod ct_await;
13pub mod ct_check;
14pub mod ct_each;
15pub mod ct_edit;
16pub mod ct_okf;
17pub mod ct_outline;
18pub mod ct_patch;
19pub mod ct_rules;
20pub mod ct_search;
21pub mod ct_steer;
22pub mod ct_test;
23pub mod ct_tree;
24pub mod ct_view;
25
26/// Every leaf tool's name paired with its clap grammar. Built-in checks
27/// (`deps`/`mods`) are probe heads, not standalone tools, and are introspected
28/// separately via their own `check_flags`.
29pub fn commands() -> Vec<(&'static str, clap::Command)> {
30    vec![
31        ("ct-await", ct_await::Cli::command()),
32        ("ct-check", ct_check::Cli::command()),
33        ("ct-each", ct_each::Cli::command()),
34        ("ct-edit", ct_edit::Cli::command()),
35        ("ct-okf", ct_okf::Cli::command()),
36        ("ct-outline", ct_outline::Cli::command()),
37        ("ct-patch", ct_patch::Cli::command()),
38        ("ct-rules", ct_rules::Cli::command()),
39        ("ct-search", ct_search::Cli::command()),
40        ("ct-steer", ct_steer::Cli::command()),
41        ("ct-test", ct_test::Cli::command()),
42        ("ct-tree", ct_tree::Cli::command()),
43        ("ct-view", ct_view::Cli::command()),
44    ]
45}
46
47/// Every leaf tool's name paired with its introspected [`crate::deps::Grammar`]
48/// (flag specs + clap-required names). The introspection behind the schema-drift
49/// guard; uses the same reader as the built-in checks ([`crate::deps::grammar`]).
50pub fn grammars() -> Vec<(&'static str, crate::deps::Grammar)> {
51    commands()
52        .into_iter()
53        .map(|(name, command)| (name, crate::deps::grammar(command)))
54        .collect()
55}