blob: f176594e6ac9ca4923a1d4b275e669acaaabfe30 (
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
|
//! The `list` subcommand.
use crate::client::BackupClient;
use crate::config::ClientConfig;
use crate::error::ObnamError;
use structopt::StructOpt;
use tokio::runtime::Runtime;
/// List generations on the server.
#[derive(Debug, StructOpt)]
pub struct List {}
impl List {
/// 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 client = BackupClient::new(config)?;
let generations = client.list_generations().await?;
for finished in generations.iter() {
println!("{} {}", finished.id(), finished.ended());
}
Ok(())
}
}
|