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_outline;
17pub mod ct_patch;
18pub mod ct_rules;
19pub mod ct_search;
20pub mod ct_test;
21pub mod ct_tree;
22pub mod ct_view;
23
24/// Every leaf tool's name paired with its clap grammar. Built-in checks
25/// (`deps`/`mods`) are probe heads, not standalone tools, and are introspected
26/// separately via their own `check_flags`.
27pub fn commands() -> Vec<(&'static str, clap::Command)> {
28 vec![
29 ("ct-await", ct_await::Cli::command()),
30 ("ct-check", ct_check::Cli::command()),
31 ("ct-each", ct_each::Cli::command()),
32 ("ct-edit", ct_edit::Cli::command()),
33 ("ct-outline", ct_outline::Cli::command()),
34 ("ct-patch", ct_patch::Cli::command()),
35 ("ct-rules", ct_rules::Cli::command()),
36 ("ct-search", ct_search::Cli::command()),
37 ("ct-test", ct_test::Cli::command()),
38 ("ct-tree", ct_tree::Cli::command()),
39 ("ct-view", ct_view::Cli::command()),
40 ]
41}
42
43/// Every leaf tool's name paired with its introspected [`crate::deps::Grammar`]
44/// (flag specs + clap-required names). The introspection behind the schema-drift
45/// guard; uses the same reader as the built-in checks ([`crate::deps::grammar`]).
46pub fn grammars() -> Vec<(&'static str, crate::deps::Grammar)> {
47 commands()
48 .into_iter()
49 .map(|(name, command)| (name, crate::deps::grammar(command)))
50 .collect()
51}