diff --git a/src/bin/pbs-datastore.rs b/src/bin/pbs-datastore.rs index b1f1960d..fdf092d9 100644 --- a/src/bin/pbs-datastore.rs +++ b/src/bin/pbs-datastore.rs @@ -5,29 +5,29 @@ use std::collections::HashMap; use apitest::api3; use apitest::cli::command::*; -fn datastore_commands() -> CmdDef { +fn datastore_commands() -> CommandLineInterface { let mut cmd_def = HashMap::new(); - cmd_def.insert("list".to_owned(), CmdDef::Simple(CliCommand { + cmd_def.insert("list".to_owned(), CommandLineInterface::Simple(CliCommand { info: api3::config::datastore::get(), arg_param: vec![], fixed_param: vec![], })); - cmd_def.insert("create".to_owned(), CmdDef::Simple(CliCommand { + cmd_def.insert("create".to_owned(), CommandLineInterface::Simple(CliCommand { info: api3::config::datastore::post(), arg_param: vec!["name", "path"], fixed_param: vec![], })); - cmd_def.insert("remove".to_owned(), CmdDef::Simple(CliCommand { + cmd_def.insert("remove".to_owned(), CommandLineInterface::Simple(CliCommand { info: api3::config::datastore::delete(), arg_param: vec!["name"], fixed_param: vec![], })); - CmdDef::Nested(cmd_def) + CommandLineInterface::Nested(cmd_def) } fn main() { @@ -36,7 +36,7 @@ fn main() { cmd_def.insert("datastore".to_owned(), datastore_commands()); - if let Err(err) = run_cli_command(&CmdDef::Nested(cmd_def)) { + if let Err(err) = run_cli_command(&CommandLineInterface::Nested(cmd_def)) { eprintln!("Error: {}", err); print_cli_usage(); std::process::exit(-1); diff --git a/src/cli/command.rs b/src/cli/command.rs index f817d6fd..2ad46377 100644 --- a/src/cli/command.rs +++ b/src/cli/command.rs @@ -27,7 +27,7 @@ fn handle_simple_command(cli_cmd: &CliCommand, args: Vec) -> Result<(), Ok(()) } -fn handle_nested_command(def: &HashMap, mut args: Vec) -> Result<(), Error> { +fn handle_nested_command(def: &HashMap, mut args: Vec) -> Result<(), Error> { if args.len() < 1 { let mut cmds: Vec<&String> = def.keys().collect(); @@ -52,10 +52,10 @@ fn handle_nested_command(def: &HashMap, mut args: Vec) - }; match sub_cmd { - CmdDef::Simple(cli_cmd) => { + CommandLineInterface::Simple(cli_cmd) => { handle_simple_command(cli_cmd, args)?; } - CmdDef::Nested(map) => { + CommandLineInterface::Nested(map) => { handle_nested_command(map, args)?; } } @@ -63,13 +63,13 @@ fn handle_nested_command(def: &HashMap, mut args: Vec) - Ok(()) } -pub fn run_cli_command(def: &CmdDef) -> Result<(), Error> { +pub fn run_cli_command(def: &CommandLineInterface) -> Result<(), Error> { let args: Vec = std::env::args().skip(1).collect(); match def { - CmdDef::Simple(cli_cmd) => handle_simple_command(cli_cmd, args), - CmdDef::Nested(map) => handle_nested_command(map, args), + CommandLineInterface::Simple(cli_cmd) => handle_simple_command(cli_cmd, args), + CommandLineInterface::Nested(map) => handle_nested_command(map, args), } } @@ -79,7 +79,7 @@ pub struct CliCommand { pub fixed_param: Vec<&'static str>, } -pub enum CmdDef { +pub enum CommandLineInterface { Simple(CliCommand), - Nested(HashMap), + Nested(HashMap), }