Skip to main content

spec_driven_docs/cli/
reconcile.rs

1//! `reconcile` subcommand: parse-shape.
2//!
3//! Holds the clap derive structs only. No I/O, no business logic.
4
5use camino::Utf8PathBuf;
6use clap::Subcommand;
7
8/// Compute, read, and apply one plan.
9#[derive(Debug, clap::Args)]
10pub struct ReconcileArgs {
11    /// The verb to run.
12    #[command(subcommand)]
13    pub command: ReconcileCommand,
14}
15
16/// Every verb `sdd reconcile` offers.
17#[derive(Debug, Subcommand)]
18pub enum ReconcileCommand {
19    /// Compute one plan, store it, and print it.
20    Plan(PlanArgs),
21    /// Render one stored plan, or the latest result for its id.
22    Show(ShowArgs),
23    /// Execute one stored plan, or refuse because its inputs moved.
24    Apply(ApplyArgs),
25}
26
27/// Render one stored plan, or the latest result for its id.
28#[derive(Debug, clap::Args)]
29pub struct ShowArgs {
30    /// The plan's id, which is its fingerprint.
31    pub plan_id: String,
32
33    /// Print one JSON object instead of text.
34    #[arg(long)]
35    pub json: bool,
36}
37
38/// Execute one stored plan.
39#[derive(Debug, clap::Args)]
40pub struct ApplyArgs {
41    /// The plan's id, which is its fingerprint.
42    pub plan_id: String,
43
44    /// The repository to apply to; absolute, or the working directory.
45    #[arg(long, default_value = ".")]
46    pub target: Utf8PathBuf,
47
48    /// Print one JSON object instead of text.
49    #[arg(long)]
50    pub json: bool,
51}
52
53/// Compute one plan, store it, and print it.
54#[derive(Debug, clap::Args)]
55pub struct PlanArgs {
56    /// The repository to plan for; absolute, or the working directory.
57    #[arg(long, default_value = ".")]
58    pub target: Utf8PathBuf,
59
60    /// The destination release: `embedded`, `latest`, or a version.
61    ///
62    /// The default is the release this binary carries, which keeps the
63    /// default offline.
64    #[arg(long, default_value = "embedded")]
65    pub to: String,
66
67    /// Forbid every network read.
68    #[arg(long)]
69    pub offline: bool,
70
71    /// Answer one decision the plan offers, as `<decision-id>=<answer>`.
72    ///
73    /// Repeatable. Selecting a decision is what re-plans with it, so an
74    /// approval binds to the answers it was given with.
75    #[arg(long = "set", value_name = "DECISION=ANSWER")]
76    pub set: Vec<String>,
77
78    /// A path no delivered gate judges. Repeatable.
79    ///
80    /// A region another tool renders or hashes. It changes what the
81    /// landing writes, so it is part of the plan rather than a flag on
82    /// the apply.
83    #[arg(long, value_name = "PATH")]
84    pub reserve: Vec<String>,
85
86    /// Print one JSON object instead of text.
87    #[arg(long)]
88    pub json: bool,
89}