Skip to main content

spec_driven_docs/
cli.rs

1//! Root clap parser.
2//!
3//! Holds the top-level [`Cli`], the [`Commands`] enum, and the global args.
4//! Per-subcommand arg structs live in sibling files (`cli/<name>.rs`). No
5//! business logic anywhere in this module tree.
6
7pub mod assess;
8pub mod completions;
9pub mod doctor;
10pub mod gate;
11pub mod hooks;
12pub mod init;
13pub mod ki;
14pub mod license;
15pub mod read;
16pub mod skill;
17pub mod status;
18pub mod track;
19pub mod upgrade;
20pub mod verify;
21
22use clap::{ArgAction, Parser, Subcommand};
23
24/// The `sdd` command line.
25#[derive(Debug, Parser)]
26#[command(name = "sdd", version, about, long_about = None)]
27pub struct Cli {
28    /// Flags every subcommand shares.
29    #[command(flatten)]
30    pub global: GlobalArgs,
31
32    /// The subcommand to run.
33    #[command(subcommand)]
34    pub command: Commands,
35}
36
37/// Flags every subcommand shares.
38#[derive(Debug, clap::Args)]
39pub struct GlobalArgs {
40    /// Increase log verbosity (-v info, -vv debug, -vvv trace).
41    /// Overridden by `RUST_LOG` if set.
42    #[arg(short, long, action = ArgAction::Count, global = true)]
43    pub verbose: u8,
44}
45
46/// Every subcommand `sdd` offers.
47#[derive(Debug, Subcommand)]
48pub enum Commands {
49    /// Install the payload into a target repository.
50    Init(init::InitArgs),
51    /// Verify an installed instance offline.
52    Verify(verify::VerifyArgs),
53    /// Upgrade an installed instance to this binary's version.
54    Upgrade(upgrade::UpgradeArgs),
55    /// Run one delivered gate, or list them all.
56    Gate(gate::GateArgs),
57    /// Render the delivered gate set as pre-commit hook entries.
58    Hooks(hooks::HooksArgs),
59    /// Read the known-issue zone.
60    Ki(ki::KiArgs),
61    /// Read a method chapter, or list them.
62    Method(read::ReadArgs),
63    /// Read a spec seed, or list them.
64    Spec(read::ReadArgs),
65    /// Read a document template, or list them.
66    Template(read::ReadArgs),
67    /// Read the embedded skills, or install them for coding agents.
68    Skill(skill::SkillArgs),
69    /// Report an instance's state without gating on it.
70    Status(status::StatusArgs),
71    /// Report tracking freshness offline, or check upstreams over the network.
72    Track(track::TrackArgs),
73    /// Probe this host's readiness and report by class; never fails.
74    Doctor(doctor::DoctorArgs),
75    /// Classify a target repository before anything lands; every classification exits 0.
76    Assess(assess::AssessArgs),
77    /// Print the license terms this binary carries.
78    License(license::LicenseArgs),
79    /// Regenerate the canon checkout's own instance manifest.
80    SelfManifest,
81    /// Generate shell completions.
82    Completions(completions::CompletionsArgs),
83    /// Render the manual page.
84    Man,
85}
86
87/// Every subcommand name the binary answers to.
88#[must_use]
89pub fn subcommand_names() -> Vec<String> {
90    <Cli as clap::CommandFactory>::command()
91        .get_subcommands()
92        .map(|command| command.get_name().to_string())
93        .collect()
94}