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 completions;
8pub mod gate;
9pub mod hooks;
10pub mod init;
11pub mod license;
12pub mod read;
13pub mod upgrade;
14pub mod verify;
15
16use clap::{ArgAction, Parser, Subcommand};
17
18/// The `sdd` command line.
19#[derive(Debug, Parser)]
20#[command(name = "sdd", version, about, long_about = None)]
21pub struct Cli {
22 /// Flags every subcommand shares.
23 #[command(flatten)]
24 pub global: GlobalArgs,
25
26 /// The subcommand to run.
27 #[command(subcommand)]
28 pub command: Commands,
29}
30
31/// Flags every subcommand shares.
32#[derive(Debug, clap::Args)]
33pub struct GlobalArgs {
34 /// Increase log verbosity (-v info, -vv debug, -vvv trace).
35 /// Overridden by `RUST_LOG` if set.
36 #[arg(short, long, action = ArgAction::Count, global = true)]
37 pub verbose: u8,
38}
39
40/// Every subcommand `sdd` offers.
41#[derive(Debug, Subcommand)]
42pub enum Commands {
43 /// Install the payload into a target repository.
44 Init(init::InitArgs),
45 /// Verify an installed instance offline.
46 Verify(verify::VerifyArgs),
47 /// Upgrade an installed instance to this binary's version.
48 Upgrade(upgrade::UpgradeArgs),
49 /// Run one delivered gate, or list them all.
50 Gate(gate::GateArgs),
51 /// Render the delivered gate set as pre-commit hook entries.
52 Hooks(hooks::HooksArgs),
53 /// Read a method chapter, or list them.
54 Method(read::ReadArgs),
55 /// Read a spec seed, or list them.
56 Spec(read::ReadArgs),
57 /// Read a document template, or list them.
58 Template(read::ReadArgs),
59 /// Print the license terms this binary carries.
60 License(license::LicenseArgs),
61 /// Regenerate the canon checkout's own instance manifest.
62 SelfManifest,
63 /// Generate shell completions.
64 Completions(completions::CompletionsArgs),
65 /// Render the manual page.
66 Man,
67}