blob: 2663d9bf968d30221f454b9be6f5951ce30e7492 (
plain)
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
38
39
40
41
|
//! The `gen-info` subcommand.
use crate::client::AsyncBackupClient;
use crate::config::ClientConfig;
use crate::error::ObnamError;
use log::info;
use structopt::StructOpt;
use tempfile::NamedTempFile;
use tokio::runtime::Runtime;
/// Show metadata for a generation.
#[derive(Debug, StructOpt)]
pub struct GenInfo {
/// Reference of the generation.
#[structopt()]
gen_ref: String,
}
impl GenInfo {
/// Run the command.
pub fn run(&self, config: &ClientConfig) -> Result<(), ObnamError> {
let rt = Runtime::new()?;
rt.block_on(self.run_async(config))
}
async fn run_async(&self, config: &ClientConfig) -> Result<(), ObnamError> {
let temp = NamedTempFile::new()?;
let client = AsyncBackupClient::new(config)?;
let genlist = client.list_generations().await?;
let gen_id = genlist.resolve(&self.gen_ref)?;
info!("generation id is {}", gen_id.as_chunk_id());
let gen = client.fetch_generation(&gen_id, temp.path()).await?;
let meta = gen.meta()?;
println!("{}", serde_json::to_string_pretty(&meta)?);
Ok(())
}
}
|