implement builder pattern for CliCommand

This commit is contained in:
Dietmar Maurer
2018-12-11 11:12:13 +01:00
parent baed30b702
commit bf7f103944
2 changed files with 28 additions and 15 deletions

View File

@ -99,6 +99,23 @@ pub struct CliCommand {
pub fixed_param: Vec<&'static str>,
}
impl CliCommand {
pub fn new(info: ApiMethod) -> Self {
Self { info, arg_param: vec![], fixed_param: vec![] }
}
pub fn arg_param(mut self, names: Vec<&'static str>) -> Self {
self.arg_param = names;
self
}
pub fn fixed_param(mut self, args: Vec<&'static str>) -> Self {
self.fixed_param = args;
self
}
}
pub enum CommandLineInterface {
Simple(CliCommand),
Nested(HashMap<String, CommandLineInterface>),