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