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
42
43
44
|
use log::{debug, info};
use obnam::cmd::{backup, list, restore};
use std::path::PathBuf;
use structopt::StructOpt;
const BUFFER_SIZE: usize = 1024 * 1024;
fn main() -> anyhow::Result<()> {
pretty_env_logger::init();
let opt = Opt::from_args();
info!("obnam starts");
debug!("opt: {:?}", opt);
match opt {
Opt::Backup { config } => backup(&config, BUFFER_SIZE)?,
Opt::List { config } => list(&config)?,
Opt::Restore { config, gen_id, to } => restore(&config, &gen_id, &to)?,
}
Ok(())
}
#[derive(Debug, StructOpt)]
#[structopt(name = "obnam-backup", about = "Simplistic backup client")]
enum Opt {
Backup {
#[structopt(parse(from_os_str))]
config: PathBuf,
},
List {
#[structopt(parse(from_os_str))]
config: PathBuf,
},
Restore {
#[structopt(parse(from_os_str))]
config: PathBuf,
#[structopt()]
gen_id: String,
#[structopt(parse(from_os_str))]
to: PathBuf,
},
}
|