mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 08:50:19 +00:00
chore: run fmt
This commit is contained in:
1 parent
17aca87df9
commit
fcaa6d32dc
3 files changed
+25
-8
No files matched your search
+3
-1
@@ -1,6 +1,8 @@
|
|||||||
use std::ffi::OsString;
|
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
|
pub fn get_cli_arguments<'a, I, T>(args: I) -> ArgMatches
|
||||||
where
|
where
|
||||||
|
|||||||
+18
-6
@@ -10,7 +10,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use clap::{ArgMatches, parser::ValuesRef};
|
use clap::{parser::ValuesRef, ArgMatches};
|
||||||
|
|
||||||
use crate::parameter::tokenize::tokenize;
|
use crate::parameter::tokenize::tokenize;
|
||||||
use crate::parameter::ParameterValue;
|
use crate::parameter::ParameterValue;
|
||||||
@@ -118,10 +118,16 @@ pub struct Commands<'a>(Vec<Command<'a>>);
|
|||||||
impl<'a> Commands<'a> {
|
impl<'a> Commands<'a> {
|
||||||
pub fn from_cli_arguments(matches: &'a ArgMatches) -> Result<Commands> {
|
pub fn from_cli_arguments(matches: &'a ArgMatches) -> Result<Commands> {
|
||||||
let command_names = matches.get_many::<String>("command-name");
|
let command_names = matches.get_many::<String>("command-name");
|
||||||
let command_strings = matches.get_many::<String>("command").unwrap_or_default().map(|v| v.as_str()).collect::<Vec<_>>();
|
let command_strings = matches
|
||||||
|
.get_many::<String>("command")
|
||||||
|
.unwrap_or_default()
|
||||||
|
.map(|v| v.as_str())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
if let Some(args) = matches.get_many::<String>("parameter-scan") {
|
if let Some(args) = matches.get_many::<String>("parameter-scan") {
|
||||||
let step_size = matches.get_one::<String>("parameter-step-size").map(|s| s.as_str());
|
let step_size = matches
|
||||||
|
.get_one::<String>("parameter-step-size")
|
||||||
|
.map(|s| s.as_str());
|
||||||
Ok(Self(Self::get_parameter_scan_commands(
|
Ok(Self(Self::get_parameter_scan_commands(
|
||||||
command_names,
|
command_names,
|
||||||
command_strings,
|
command_strings,
|
||||||
@@ -129,7 +135,9 @@ impl<'a> Commands<'a> {
|
|||||||
step_size,
|
step_size,
|
||||||
)?))
|
)?))
|
||||||
} else if let Some(args) = matches.get_many::<String>("parameter-list") {
|
} else if let Some(args) = matches.get_many::<String>("parameter-list") {
|
||||||
let command_names = command_names.map_or(vec![], |names| names.map(|v| v.as_str()).collect::<Vec<_>>());
|
let command_names = command_names.map_or(vec![], |names| {
|
||||||
|
names.map(|v| v.as_str()).collect::<Vec<_>>()
|
||||||
|
});
|
||||||
let args: Vec<_> = args.map(|v| v.as_str()).collect::<Vec<_>>();
|
let args: Vec<_> = args.map(|v| v.as_str()).collect::<Vec<_>>();
|
||||||
let param_names_and_values: Vec<(&str, Vec<String>)> = args
|
let param_names_and_values: Vec<(&str, Vec<String>)> = args
|
||||||
.chunks_exact(2)
|
.chunks_exact(2)
|
||||||
@@ -207,7 +215,9 @@ impl<'a> Commands<'a> {
|
|||||||
|
|
||||||
Ok(Self(commands))
|
Ok(Self(commands))
|
||||||
} else {
|
} else {
|
||||||
let command_names = command_names.map_or(vec![], |names| names.map(|v| v.as_str()).collect::<Vec<_>>());
|
let command_names = command_names.map_or(vec![], |names| {
|
||||||
|
names.map(|v| v.as_str()).collect::<Vec<_>>()
|
||||||
|
});
|
||||||
if command_names.len() > command_strings.len() {
|
if command_names.len() > command_strings.len() {
|
||||||
return Err(OptionsError::TooManyCommandNames(command_strings.len()).into());
|
return Err(OptionsError::TooManyCommandNames(command_strings.len()).into());
|
||||||
}
|
}
|
||||||
@@ -288,7 +298,9 @@ impl<'a> Commands<'a> {
|
|||||||
mut vals: ValuesRef<'b, String>,
|
mut vals: ValuesRef<'b, String>,
|
||||||
step: Option<&str>,
|
step: Option<&str>,
|
||||||
) -> Result<Vec<Command<'b>>, ParameterScanError> {
|
) -> Result<Vec<Command<'b>>, ParameterScanError> {
|
||||||
let command_names = command_names.map_or(vec![], |names| names.map(|v| v.as_str()).collect::<Vec<_>>());
|
let command_names = command_names.map_or(vec![], |names| {
|
||||||
|
names.map(|v| v.as_str()).collect::<Vec<_>>()
|
||||||
|
});
|
||||||
let command_strings = command_strings;
|
let command_strings = command_strings;
|
||||||
let param_name = vals.next().unwrap().as_str();
|
let param_name = vals.next().unwrap().as_str();
|
||||||
let param_min = vals.next().unwrap().as_str();
|
let param_min = vals.next().unwrap().as_str();
|
||||||
|
|||||||
+4
-1
@@ -325,7 +325,10 @@ impl Options {
|
|||||||
options.executor_kind = if matches.get_flag("no-shell") {
|
options.executor_kind = if matches.get_flag("no-shell") {
|
||||||
ExecutorKind::Raw
|
ExecutorKind::Raw
|
||||||
} else {
|
} else {
|
||||||
match (matches.get_flag("debug-mode"), matches.get_one::<String>("shell")) {
|
match (
|
||||||
|
matches.get_flag("debug-mode"),
|
||||||
|
matches.get_one::<String>("shell"),
|
||||||
|
) {
|
||||||
(false, Some(shell)) if shell == "default" => ExecutorKind::Shell(Shell::default()),
|
(false, Some(shell)) if shell == "default" => ExecutorKind::Shell(Shell::default()),
|
||||||
(false, Some(shell)) if shell == "none" => ExecutorKind::Raw,
|
(false, Some(shell)) if shell == "none" => ExecutorKind::Raw,
|
||||||
(false, Some(shell)) => ExecutorKind::Shell(Shell::parse_from_str(shell)?),
|
(false, Some(shell)) => ExecutorKind::Shell(Shell::parse_from_str(shell)?),
|
||||||
|
|||||||
Reference in new issue
Block a user