Skip to main content

asimov_cli/commands/
snapshot.rs

1// This is free and unencumbered software released into the public domain.
2
3use clientele::{StandardOptions, SysexitsError, crates::clap::Subcommand};
4use std::{string::String, vec::Vec};
5
6#[derive(Debug, Subcommand)]
7pub enum SnapshotCommand {
8    /// Create snapshots for URL(s)
9    #[clap(external_subcommand)]
10    Snapshot(Vec<String>),
11
12    /// List snapshots
13    List,
14
15    /// Show log for a URL
16    Log {
17        /// URL to show log for
18        url: String,
19    },
20
21    /// Compact snapshots for a URL
22    Compact {
23        /// URL(s) to compact snapshots for
24        urls: Vec<String>,
25    },
26}
27
28impl SnapshotCommand {
29    pub async fn run(&self, flags: &StandardOptions) -> Result<(), SysexitsError> {
30        use SnapshotCommand::*;
31        match self {
32            Snapshot(urls) => snapshot(urls, &flags).await,
33            List => list(&flags).await,
34            Log { url } => log(&url, &flags).await,
35            Compact { urls } => compact(&urls, &flags).await,
36        }
37    }
38}
39
40mod compact;
41pub use compact::*;
42
43mod list;
44pub use list::*;
45
46mod log;
47pub use log::*;
48
49mod snapshot;
50pub use snapshot::*;