run 'cargo fmt'

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2020-11-27 11:43:55 +01:00
parent 97509b63ad
commit b210ad69eb
2 changed files with 6 additions and 9 deletions

View File

@ -175,7 +175,6 @@ fn parse_nested_command<'a>(
return Err(format_err!("{}", err_msg)); return Err(format_err!("{}", err_msg));
} }
let command = args.remove(0); let command = args.remove(0);
let (_, sub_cmd) = match map.find_command(&command) { let (_, sub_cmd) = match map.find_command(&command) {
@ -265,15 +264,13 @@ pub(crate) fn help_command_def() -> CliCommand {
CliCommand::new(&API_METHOD_COMMAND_HELP).arg_param(&["command"]) CliCommand::new(&API_METHOD_COMMAND_HELP).arg_param(&["command"])
} }
fn replace_aliases( fn replace_aliases(args: &mut Vec<String>, aliases: &[(Vec<&'static str>, Vec<&'static str>)]) {
args: &mut Vec<String>,
aliases: &[(Vec<&'static str>, Vec<&'static str>)],
) {
for (old, new) in aliases { for (old, new) in aliases {
if args.len() < old.len() { continue; } if args.len() < old.len() {
continue;
}
if old[..] == args[..old.len()] { if old[..] == args[..old.len()] {
let new_args: Vec<String> = new.iter() let new_args: Vec<String> = new.iter().map(|s| String::from(*s)).collect();
.map(|s| String::from(*s)).collect();
let rest = args.split_off(old.len()); let rest = args.split_off(old.len());
args.truncate(0); args.truncate(0);
args.extend(new_args); args.extend(new_args);

View File

@ -116,7 +116,7 @@ impl CliCommandMap {
self self
} }
pub fn alias(mut self, old: &'static[&'static str], new: &'static[&'static str]) -> Self { pub fn alias(mut self, old: &'static [&'static str], new: &'static [&'static str]) -> Self {
self.aliases.push((Vec::from(old), Vec::from(new))); self.aliases.push((Vec::from(old), Vec::from(new)));
self self
} }