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
|
|
|
|
2018-12-10 12:40:10 +00:00
|
|
|
fn datastore_commands() -> CommandLineInterface {
|
2018-12-09 10:59:32 +00:00
|
|
|
|
2018-12-11 10:12:13 +00:00
|
|
|
use apitest::api3::config::datastore;
|
|
|
|
|
2018-12-11 10:31:36 +00:00
|
|
|
let cmd_def = CliCommandMap::new()
|
|
|
|
.insert("list", CliCommand::new(datastore::get()).into())
|
|
|
|
.insert("create",
|
|
|
|
CliCommand::new(datastore::post())
|
|
|
|
.arg_param(vec!["name", "path"])
|
|
|
|
.into())
|
|
|
|
.insert("remove",
|
|
|
|
CliCommand::new(datastore::delete())
|
|
|
|
.arg_param(vec!["name"])
|
2018-12-12 11:18:28 +00:00
|
|
|
.completion_cb("name", apitest::config::datastore::complete_datastore_name)
|
2018-12-11 10:31:36 +00:00
|
|
|
.into());
|
2018-12-10 12:28:38 +00:00
|
|
|
|
2018-12-10 12:51:10 +00:00
|
|
|
cmd_def.into()
|
2018-12-10 12:28:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
2018-12-11 10:31:36 +00:00
|
|
|
let cmd_def = CliCommandMap::new()
|
|
|
|
.insert("datastore".to_owned(), datastore_commands());
|
2018-12-09 15:52:32 +00:00
|
|
|
|
2018-12-11 10:31:36 +00:00
|
|
|
if let Err(err) = run_cli_command(&cmd_def.into()) {
|
2018-12-09 10:59:32 +00:00
|
|
|
eprintln!("Error: {}", err);
|
|
|
|
print_cli_usage();
|
|
|
|
std::process::exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|