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_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 `(long-flag, kind)` list — `kind` is
44/// `"boolean"`, `"array"`, or `"string"` — read straight from the clap grammar.
45/// The introspection behind the schema-drift guard; uses the same reader as the
46/// built-in checks ([`crate::deps::flag_kinds`]).
47pub fn flags() -> Vec<(&'static str, Vec<(String, &'static str)>)> {
48    commands()
49        .into_iter()
50        .map(|(name, command)| (name, crate::deps::flag_kinds(command)))
51        .collect()
52}