Skip to main content

asimov_cli/commands/source/
snap.rs

1// This is free and unencumbered software released into the public domain.
2
3use crate::{BoxError, StandardOptions};
4use clientele::crates::clap::Subcommand;
5use std::{string::String, vec::Vec};
6
7#[derive(Debug, Subcommand)]
8pub enum SnapCommand {
9    /// Save a snapshot of a URL, utilizing enabled modules
10    #[clap(aliases = ["create", "update"])]
11    Save {
12        #[clap(flatten)]
13        args: SnapSaveArgs,
14    },
15
16    /// List all saved snapshots
17    List,
18
19    /// Show snapshot log for a given URL
20    Log {
21        /// URL to show log for
22        url: String,
23    },
24
25    /// Compact the snapshots for a given URL
26    Compact {
27        /// URL(s) to compact snapshots for
28        urls: Vec<String>,
29    },
30}
31
32impl SnapCommand {
33    pub async fn run(&self, flags: &StandardOptions) -> Result<(), BoxError> {
34        use SnapCommand::*;
35        match self {
36            Save { args } => save(args, flags).await,
37            List => list(flags).await,
38            Log { url } => log(url, flags).await,
39            Compact { urls } => compact(urls, flags).await,
40        }
41    }
42}
43
44mod compact;
45pub use compact::*;
46
47mod create;
48pub use create::*;
49
50mod list;
51pub use list::*;
52
53mod log;
54pub use log::*;
55
56mod save;
57pub use save::*;