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