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