impl From for CommandLineInterface
This commit is contained in:
		@ -7,27 +7,27 @@ use apitest::cli::command::*;
 | 
			
		||||
 | 
			
		||||
fn datastore_commands() -> CommandLineInterface {
 | 
			
		||||
 | 
			
		||||
    let mut cmd_def = HashMap::new();
 | 
			
		||||
    let mut cmd_def = HashMap::<String, CommandLineInterface>::new();
 | 
			
		||||
 | 
			
		||||
    cmd_def.insert("list".to_owned(), CommandLineInterface::Simple(CliCommand {
 | 
			
		||||
    cmd_def.insert("list".to_owned(), CliCommand {
 | 
			
		||||
        info: api3::config::datastore::get(),
 | 
			
		||||
        arg_param: vec![],
 | 
			
		||||
        fixed_param: vec![],
 | 
			
		||||
    }));
 | 
			
		||||
    }.into());
 | 
			
		||||
 | 
			
		||||
    cmd_def.insert("create".to_owned(), CommandLineInterface::Simple(CliCommand {
 | 
			
		||||
    cmd_def.insert("create".to_owned(), CliCommand {
 | 
			
		||||
        info: api3::config::datastore::post(),
 | 
			
		||||
        arg_param: vec!["name", "path"],
 | 
			
		||||
        fixed_param: vec![],
 | 
			
		||||
    }));
 | 
			
		||||
    }.into());
 | 
			
		||||
 | 
			
		||||
    cmd_def.insert("remove".to_owned(), CommandLineInterface::Simple(CliCommand {
 | 
			
		||||
    cmd_def.insert("remove".to_owned(), CliCommand {
 | 
			
		||||
        info: api3::config::datastore::delete(),
 | 
			
		||||
        arg_param: vec!["name"],
 | 
			
		||||
        fixed_param: vec![],
 | 
			
		||||
    }));
 | 
			
		||||
    }.into());
 | 
			
		||||
 | 
			
		||||
    CommandLineInterface::Nested(cmd_def)
 | 
			
		||||
    cmd_def.into()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn main() {
 | 
			
		||||
 | 
			
		||||
@ -83,3 +83,15 @@ pub enum CommandLineInterface {
 | 
			
		||||
    Simple(CliCommand),
 | 
			
		||||
    Nested(HashMap<String, CommandLineInterface>),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl From<CliCommand> for CommandLineInterface {
 | 
			
		||||
    fn from(cli_cmd: CliCommand) -> Self {
 | 
			
		||||
         CommandLineInterface::Simple(cli_cmd)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl From<HashMap<String, CommandLineInterface>> for CommandLineInterface {
 | 
			
		||||
    fn from(map: HashMap<String, CommandLineInterface>) -> Self {
 | 
			
		||||
        CommandLineInterface::Nested(map)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user