proxmox-backup/src/bin/pbs.rs

46 lines
1.1 KiB
Rust
Raw Normal View History

extern crate apitest;
use std::collections::HashMap;
use apitest::api3;
use apitest::cli::command::*;
2018-12-10 12:40:10 +00:00
fn datastore_commands() -> CommandLineInterface {
2018-12-10 12:51:10 +00:00
let mut cmd_def = HashMap::<String, CommandLineInterface>::new();
2018-12-10 12:51:10 +00:00
cmd_def.insert("list".to_owned(), CliCommand {
info: api3::config::datastore::get(),
arg_param: vec![],
fixed_param: vec![],
2018-12-10 12:51:10 +00:00
}.into());
2018-12-10 12:51:10 +00:00
cmd_def.insert("create".to_owned(), CliCommand {
info: api3::config::datastore::post(),
arg_param: vec!["name", "path"],
fixed_param: vec![],
2018-12-10 12:51:10 +00:00
}.into());
2018-12-10 12:51:10 +00:00
cmd_def.insert("remove".to_owned(), CliCommand {
info: api3::config::datastore::delete(),
arg_param: vec!["name"],
fixed_param: vec![],
2018-12-10 12:51:10 +00:00
}.into());
2018-12-10 12:51:10 +00:00
cmd_def.into()
}
fn main() {
let mut cmd_def = HashMap::new();
cmd_def.insert("datastore".to_owned(), datastore_commands());
2018-12-10 12:40:10 +00:00
if let Err(err) = run_cli_command(&CommandLineInterface::Nested(cmd_def)) {
eprintln!("Error: {}", err);
print_cli_usage();
std::process::exit(-1);
}
}