rustic_rs/commands/
tag.rs1use abscissa_core::{Command, Runnable};
3use rustic_core::{StringList, repofile::SnapshotModification};
4
5use crate::commands::rewrite::RewriteCmd;
6
7#[derive(clap::Parser, Command, Debug)]
9pub(crate) struct TagCmd {
10 #[clap(value_name = "ID")]
14 ids: Vec<String>,
15
16 #[clap(
18 long,
19 value_name = "TAG[,TAG,..]",
20 conflicts_with = "remove",
21 help_heading = "Tag options"
22 )]
23 add: Vec<StringList>,
24
25 #[clap(long, value_name = "TAG[,TAG,..]", help_heading = "Tag options")]
27 remove: Vec<StringList>,
28
29 #[clap(
31 long,
32 value_name = "TAG[,TAG,..]",
33 conflicts_with = "remove",
34 help_heading = "Tag options"
35 )]
36 set: Vec<StringList>,
37}
38
39impl Runnable for TagCmd {
40 fn run(&self) {
41 let modification = SnapshotModification::default()
42 .add_tags(self.add.clone())
43 .remove_tags(self.remove.clone())
44 .set_tags(self.set.clone());
45 let rewrite = RewriteCmd {
46 ids: self.ids.clone(),
47 modification,
48 forget: true,
49 ..Default::default()
50 };
51 rewrite.run();
52 }
53}