cli/command.rs: add new type CliCommandMap
This commit is contained in:
@ -7,32 +7,28 @@ use apitest::cli::command::*;
|
||||
|
||||
fn datastore_commands() -> CommandLineInterface {
|
||||
|
||||
let mut cmd_def = HashMap::<String, CommandLineInterface>::new();
|
||||
|
||||
use apitest::api3::config::datastore;
|
||||
|
||||
cmd_def.insert("list".to_owned(), CliCommand::new(datastore::get()).into());
|
||||
|
||||
cmd_def.insert("create".to_owned(),
|
||||
CliCommand::new(datastore::post())
|
||||
.arg_param(vec!["name", "path"])
|
||||
.into());
|
||||
|
||||
cmd_def.insert("remove".to_owned(),
|
||||
CliCommand::new(api3::config::datastore::delete())
|
||||
.arg_param(vec!["name"])
|
||||
.into());
|
||||
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"])
|
||||
.into());
|
||||
|
||||
cmd_def.into()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
let mut cmd_def = HashMap::new();
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("datastore".to_owned(), datastore_commands());
|
||||
|
||||
cmd_def.insert("datastore".to_owned(), datastore_commands());
|
||||
|
||||
if let Err(err) = run_cli_command(&CommandLineInterface::Nested(cmd_def)) {
|
||||
if let Err(err) = run_cli_command(&cmd_def.into()) {
|
||||
eprintln!("Error: {}", err);
|
||||
print_cli_usage();
|
||||
std::process::exit(-1);
|
||||
|
Reference in New Issue
Block a user