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