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