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 policy;
18pub mod read;
19pub mod self_depend;
20pub mod skill;
21pub mod stage;
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 /// Run one delivered gate, or list them all.
61 Gate(gate::GateArgs),
62 /// Render the delivered gate set as pre-commit hook entries.
63 Hooks(hooks::HooksArgs),
64 /// Record, migrate, or tighten the inherited budget violations a project carries.
65 Debt(debt::DebtArgs),
66 /// Bring an adopted specification into agreement with what the project declared.
67 Policy(policy::PolicyArgs),
68 /// Read the known-issue zone.
69 Ki(ki::KiArgs),
70 /// Read this binary's own corpus: the index, or one topic.
71 Docs(docs::DocsArgs),
72 /// Read a method chapter, or list them.
73 Method(read::ReadArgs),
74 /// Read a spec seed, or list them.
75 Spec(read::ReadArgs),
76 /// Read a document template, or list them.
77 Template(read::ReadArgs),
78 /// Read the embedded skills, or install them for coding agents.
79 Skill(skill::SkillArgs),
80 /// Render this binary's candidate into a stage an agent reads.
81 Stage(stage::StageArgs),
82 /// Report an instance's state without gating on it.
83 Status(status::StatusArgs),
84 /// Report tracking freshness offline, or check upstreams over the network.
85 Track(track::TrackArgs),
86 /// Probe this host's readiness and report by class; never fails.
87 Doctor(doctor::DoctorArgs),
88 /// Classify a target repository before anything lands; every classification exits 0.
89 Assess(assess::AssessArgs),
90 /// Print the license terms this binary carries.
91 License(license::LicenseArgs),
92 /// Regenerate the canon checkout's own instance manifest.
93 SelfManifest,
94 /// Wire this tool as a consumer's dependency and keep its pin fresh.
95 SelfDepend(self_depend::SelfDependArgs),
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}