1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use eyre::Result;
use crate::system::history::replay::{self, UndoRequest};
/// Reverse the tracked-file changes from an operation
///
/// Restores exactly the paths that operation changed from the protective
/// checkpoint it took, leaving everything else as it is now. Without a
/// reference, the newest operation not yet undone is reversed.
/// Bootstrap, captured commands, rollback, undo, and pull are supported.
/// Package installations, service state, and untracked files are not reversed.
#[derive(Debug, usage_rs::Args)]
#[usage(verbatim_doc_comment)]
pub(crate) struct DotfilesUndo {
/// The operation's checkpoint: numeric ID, `latest`, `latest~N`, or `commit:<sha>`
#[usage(value_name = "REF")]
reference: Option<String>,
/// Show the plan without changing anything
#[usage(long, short = 'n')]
dry_run: bool,
/// Apply without prompting
#[usage(long, short)]
yes: bool,
}
impl DotfilesUndo {
pub(crate) async fn run(self) -> Result<()> {
replay::undo(UndoRequest {
reference: self.reference,
dry_run: self.dry_run,
yes: self.yes,
})
.await
}
}