Skip to main content

release_kit/cli/
migrate.rs

1//! Arguments for `rk migrate`.
2
3use camino::Utf8PathBuf;
4use clap::{Args, Subcommand};
5
6/// Carry a target off another release tool through an archive and a
7/// greenfield landing.
8#[derive(Debug, Args)]
9pub struct MigrateArgs {
10    /// What to do with the migration.
11    #[command(subcommand)]
12    pub action: MigrateAction,
13}
14
15/// The migration verbs. The archive opens a migration, the marks record
16/// the map and the loop, and the close ends it; the workspace under the
17/// state root keeps the archive and the registry between runs.
18#[derive(Debug, Subcommand)]
19pub enum MigrateAction {
20    /// List every predecessor file with its tool and its kind, and the
21    /// root files that stay in place; read-only.
22    Inventory {
23        /// The repository to read.
24        #[arg(long, default_value = ".")]
25        target: Utf8PathBuf,
26
27        /// Emit one JSON object on stdout instead of the human report.
28        #[arg(long)]
29        json: bool,
30    },
31
32    /// Move every predecessor file into a new workspace, snapshot what no
33    /// Git holds, and open the migration; preview by default. On an open
34    /// migration it takes the forge snapshots still missing.
35    Archive {
36        /// The repository to act on.
37        #[arg(long, default_value = ".")]
38        target: Utf8PathBuf,
39
40        /// Move the files and write the workspace; without it the archive
41        /// is reported and nothing is touched.
42        #[arg(long)]
43        apply: bool,
44
45        /// Recreate the archived files of the open migration from Git at
46        /// its base commit, on a clone whose workspace is gone; preview by
47        /// default, written with `--apply`. It writes the workspace alone,
48        /// never the target.
49        #[arg(long)]
50        rebuild: bool,
51
52        /// Emit one JSON object on stdout instead of the human report.
53        #[arg(long)]
54        json: bool,
55    },
56
57    /// Record a status for a source or a group, appending a dated history
58    /// entry; `--group` files a source, `--destination` names where a
59    /// group's kept content lives, and a drop names its reason.
60    Mark {
61        /// A source, by id or path, or a group, by id.
62        name: String,
63
64        /// pending, mapped, written, verified, or dropped.
65        status: String,
66
67        /// The group a source joins, created where it is new.
68        #[arg(long)]
69        group: Option<String>,
70
71        /// A topic label for a source; repeatable.
72        #[arg(long = "tag")]
73        tags: Vec<String>,
74
75        /// A destination a group's kept content lives at; repeatable.
76        #[arg(long = "destination")]
77        destinations: Vec<String>,
78
79        /// Why a source or a group is dropped.
80        #[arg(long)]
81        reason: Option<String>,
82
83        /// The repository whose migration to mark.
84        #[arg(long, default_value = ".")]
85        target: Utf8PathBuf,
86
87        /// Emit one JSON object on stdout instead of the human report.
88        #[arg(long)]
89        json: bool,
90    },
91
92    /// Report the open migration: each source's status and checksum, the
93    /// groups, the snapshots, and what still blocks the close; read-only.
94    Status {
95        /// The repository to read.
96        #[arg(long, default_value = ".")]
97        target: Utf8PathBuf,
98
99        /// Emit one JSON object on stdout instead of the human report.
100        #[arg(long)]
101        json: bool,
102    },
103
104    /// End the migration once every source is verified or dropped and the
105    /// setup proof is current, removing the configuration key; preview by
106    /// default. The workspace stays for the operator.
107    Close {
108        /// The repository to act on.
109        #[arg(long, default_value = ".")]
110        target: Utf8PathBuf,
111
112        /// Remove the key; without it the close is judged and nothing is
113        /// touched.
114        #[arg(long)]
115        apply: bool,
116
117        /// Emit one JSON object on stdout instead of the human report.
118        #[arg(long)]
119        json: bool,
120    },
121}