From fcaa6d32dc97cb9eb92a8aaf74fed60bf825abf2 Mon Sep 17 00:00:00 2001 From: Benjamin Rombaut Date: Fri, 28 Oct 2022 11:23:03 +0200 Subject: [PATCH] chore: run fmt --- src/cli.rs | 4 +++- src/command.rs | 24 ++++++++++++++++++------ src/options.rs | 5 ++++- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 33ad6fc..d05455d 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,6 +1,8 @@ use std::ffi::OsString; -use clap::{crate_version, Arg, ArgMatches, Command, builder::NonEmptyStringValueParser, ArgAction}; +use clap::{ + builder::NonEmptyStringValueParser, crate_version, Arg, ArgAction, ArgMatches, Command, +}; pub fn get_cli_arguments<'a, I, T>(args: I) -> ArgMatches where diff --git a/src/command.rs b/src/command.rs index f70fac3..8017931 100644 --- a/src/command.rs +++ b/src/command.rs @@ -10,7 +10,7 @@ use crate::{ }, }; -use clap::{ArgMatches, parser::ValuesRef}; +use clap::{parser::ValuesRef, ArgMatches}; use crate::parameter::tokenize::tokenize; use crate::parameter::ParameterValue; @@ -118,10 +118,16 @@ pub struct Commands<'a>(Vec>); impl<'a> Commands<'a> { pub fn from_cli_arguments(matches: &'a ArgMatches) -> Result { let command_names = matches.get_many::("command-name"); - let command_strings = matches.get_many::("command").unwrap_or_default().map(|v| v.as_str()).collect::>(); + let command_strings = matches + .get_many::("command") + .unwrap_or_default() + .map(|v| v.as_str()) + .collect::>(); if let Some(args) = matches.get_many::("parameter-scan") { - let step_size = matches.get_one::("parameter-step-size").map(|s| s.as_str()); + let step_size = matches + .get_one::("parameter-step-size") + .map(|s| s.as_str()); Ok(Self(Self::get_parameter_scan_commands( command_names, command_strings, @@ -129,7 +135,9 @@ impl<'a> Commands<'a> { step_size, )?)) } else if let Some(args) = matches.get_many::("parameter-list") { - let command_names = command_names.map_or(vec![], |names| names.map(|v| v.as_str()).collect::>()); + let command_names = command_names.map_or(vec![], |names| { + names.map(|v| v.as_str()).collect::>() + }); let args: Vec<_> = args.map(|v| v.as_str()).collect::>(); let param_names_and_values: Vec<(&str, Vec)> = args .chunks_exact(2) @@ -207,7 +215,9 @@ impl<'a> Commands<'a> { Ok(Self(commands)) } else { - let command_names = command_names.map_or(vec![], |names| names.map(|v| v.as_str()).collect::>()); + let command_names = command_names.map_or(vec![], |names| { + names.map(|v| v.as_str()).collect::>() + }); if command_names.len() > command_strings.len() { return Err(OptionsError::TooManyCommandNames(command_strings.len()).into()); } @@ -288,7 +298,9 @@ impl<'a> Commands<'a> { mut vals: ValuesRef<'b, String>, step: Option<&str>, ) -> Result>, ParameterScanError> { - let command_names = command_names.map_or(vec![], |names| names.map(|v| v.as_str()).collect::>()); + let command_names = command_names.map_or(vec![], |names| { + names.map(|v| v.as_str()).collect::>() + }); let command_strings = command_strings; let param_name = vals.next().unwrap().as_str(); let param_min = vals.next().unwrap().as_str(); diff --git a/src/options.rs b/src/options.rs index 65741c7..086991e 100644 --- a/src/options.rs +++ b/src/options.rs @@ -325,7 +325,10 @@ impl Options { options.executor_kind = if matches.get_flag("no-shell") { ExecutorKind::Raw } else { - match (matches.get_flag("debug-mode"), matches.get_one::("shell")) { + match ( + matches.get_flag("debug-mode"), + matches.get_one::("shell"), + ) { (false, Some(shell)) if shell == "default" => ExecutorKind::Shell(Shell::default()), (false, Some(shell)) if shell == "none" => ExecutorKind::Raw, (false, Some(shell)) => ExecutorKind::Shell(Shell::parse_from_str(shell)?),