2018-12-09 10:59:32 +00:00
|
|
|
extern crate apitest;
|
|
|
|
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
use apitest::api3;
|
2018-12-10 12:36:52 +00:00
|
|
|
use apitest::cli::command::*;
|
2018-12-10 12:28:38 +00:00
|
|
|
|
|
|
|
fn datastore_commands() -> CmdDef {
|
2018-12-09 10:59:32 +00:00
|
|
|
|
|
|
|
let mut cmd_def = HashMap::new();
|
|
|
|
|
2018-12-10 12:28:38 +00:00
|
|
|
cmd_def.insert("list".to_owned(), CmdDef::Simple(CliCommand {
|
2018-12-09 10:59:32 +00:00
|
|
|
info: api3::config::datastore::get(),
|
|
|
|
arg_param: vec![],
|
|
|
|
fixed_param: vec![],
|
2018-12-10 12:28:38 +00:00
|
|
|
}));
|
2018-12-09 10:59:32 +00:00
|
|
|
|
2018-12-10 12:28:38 +00:00
|
|
|
cmd_def.insert("create".to_owned(), CmdDef::Simple(CliCommand {
|
2018-12-09 10:59:32 +00:00
|
|
|
info: api3::config::datastore::post(),
|
|
|
|
arg_param: vec!["name", "path"],
|
|
|
|
fixed_param: vec![],
|
2018-12-10 12:28:38 +00:00
|
|
|
}));
|
2018-12-09 10:59:32 +00:00
|
|
|
|
2018-12-10 12:28:38 +00:00
|
|
|
cmd_def.insert("remove".to_owned(), CmdDef::Simple(CliCommand {
|
2018-12-09 15:52:32 +00:00
|
|
|
info: api3::config::datastore::delete(),
|
|
|
|
arg_param: vec!["name"],
|
|
|
|
fixed_param: vec![],
|
2018-12-10 12:28:38 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
CmdDef::Nested(cmd_def)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
|
|
|
let mut cmd_def = HashMap::new();
|
|
|
|
|
|
|
|
cmd_def.insert("datastore".to_owned(), datastore_commands());
|
2018-12-09 15:52:32 +00:00
|
|
|
|
2018-12-10 12:28:38 +00:00
|
|
|
if let Err(err) = run_cli_command(&CmdDef::Nested(cmd_def)) {
|
2018-12-09 10:59:32 +00:00
|
|
|
eprintln!("Error: {}", err);
|
|
|
|
print_cli_usage();
|
|
|
|
std::process::exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|