rustic_rs/commands/
tag.rs

1//! `tag` subcommand
2use abscissa_core::{Command, Runnable};
3use rustic_core::StringList;
4
5use crate::commands::rewrite::RewriteCmd;
6
7/// `tag` subcommand
8#[derive(clap::Parser, Command, Debug)]
9pub(crate) struct TagCmd {
10    /// Snapshots to change tags. If none is given, use filter to filter from all
11    /// snapshots.
12    #[clap(value_name = "ID")]
13    ids: Vec<String>,
14
15    /// Tags to add (can be specified multiple times)
16    #[clap(
17        long,
18        value_name = "TAG[,TAG,..]",
19        conflicts_with = "remove",
20        help_heading = "Tag options"
21    )]
22    add: Vec<StringList>,
23
24    /// Tags to remove (can be specified multiple times)
25    #[clap(long, value_name = "TAG[,TAG,..]", help_heading = "Tag options")]
26    remove: Vec<StringList>,
27
28    /// Tag list to set (can be specified multiple times)
29    #[clap(
30        long,
31        value_name = "TAG[,TAG,..]",
32        conflicts_with = "remove",
33        help_heading = "Tag options"
34    )]
35    set: Vec<StringList>,
36}
37
38impl Runnable for TagCmd {
39    fn run(&self) {
40        let rewrite = RewriteCmd {
41            ids: self.ids.clone(),
42            add_tags: self.add.clone(),
43            remove_tags: self.remove.clone(),
44            set_tags: self.set.clone(),
45            ..Default::default()
46        };
47        rewrite.run();
48    }
49}