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