Skip to content
Myr

add clap deprecation notices

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Benjamin Rombaut · committed by David Peter · parent 83e214e · Browse files · 4 files+44 added−19 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+44 added−19 removed

  • other:+44 added−19 removed

4 files+44 added−19 removed

modified:src/export/mod.rs+1 added-1 removed
61 unmodified lines
62 pub fn from_cli_arguments(matches: &ArgMatches) -> Result<Self> {63 let mut export_manager = Self::default();64 {65 let mut add_exporter = |flag, exporttype| -> Result<()> {66 if let Some(filename) = matches.value_of(flag) {66 if let Some(filename) = matches.get_one::<String>(flag) {67 export_manager.add_exporter(exporttype, filename)?;68 }69 Ok(())70 };
45 unmodified lines
modified:src/cli.rs+30 added-5 removed
1use std::ffi::OsString;23use clap::{crate_version, AppSettings, Arg, ArgMatches, Command};3use clap::{crate_version, AppSettings, Arg, ArgMatches, Command, builder::NonEmptyStringValueParser, ArgAction};45pub fn get_cli_arguments<'a, I, T>(args: I) -> ArgMatches6where7 I: IntoIterator<Item = T>,
19 unmodified lines
27 The latter is only available if the shell is not explicitly disabled via \28 '--shell=none'. If multiple commands are given, hyperfine will show a \29 comparison of the respective runtimes.")30 .required(true)31 .action(ArgAction::StoreValue)32 .multiple_occurrences(true)32 .forbid_empty_values(true),33 .value_parser(NonEmptyStringValueParser::new()),34 )35 .arg(36 Arg::new("warmup")37 .long("warmup")38 .short('w')39 .takes_value(true)40 .value_name("NUM")41 .action(ArgAction::StoreValue)42 .help(43 "Perform NUM warmup runs before the actual benchmark. This can be used \44 to fill (disk) caches for I/O-heavy programs.",45 ),
2 unmodified lines
48 Arg::new("min-runs")49 .long("min-runs")50 .short('m')51 .takes_value(true)52 .action(ArgAction::StoreValue)53 .value_name("NUM")54 .help("Perform at least NUM runs for each command (default: 10)."),55 )56 .arg(57 Arg::new("max-runs")58 .long("max-runs")59 .short('M')60 .takes_value(true)61 .action(ArgAction::StoreValue)62 .value_name("NUM")63 .help("Perform at most NUM runs for each command. By default, there is no limit."),64 )65 .arg(
1 unmodified line
67 .long("runs")68 .conflicts_with_all(&["max-runs", "min-runs"])69 .short('r')70 .takes_value(true)71 .action(ArgAction::StoreValue)72 .value_name("NUM")73 .help("Perform exactly NUM runs for each command. If this option is not specified, \74 hyperfine automatically determines the number of runs."),75 )
1 unmodified line
77 Arg::new("setup")78 .long("setup")79 .short('s')80 .takes_value(true)81 .action(ArgAction::StoreValue)82 .number_of_values(1)83 .value_name("CMD")84 .help(85 "Execute CMD before each set of timing runs. This is useful for \
6 unmodified lines
92 Arg::new("prepare")93 .long("prepare")94 .short('p')95 .takes_value(true)96 .action(ArgAction::StoreValue)97 .multiple_occurrences(true)98 .number_of_values(1)99 .value_name("CMD")100 .help(
7 unmodified lines
108 .arg(109 Arg::new("cleanup")110 .long("cleanup")111 .short('c')112 .action(ArgAction::StoreValue)113 .takes_value(true)114 .value_name("CMD")115 .help(116 "Execute CMD after the completion of all benchmarking \
6 unmodified lines
123 Arg::new("parameter-scan")124 .long("parameter-scan")125 .short('P')126 .takes_value(true)127 .action(ArgAction::StoreValue)128 .allow_hyphen_values(true)129 .value_names(&["VAR", "MIN", "MAX"])130 .help(131 "Perform benchmark runs for each value in the range MIN..MAX. Replaces the \
10 unmodified lines
142 Arg::new("parameter-step-size")143 .long("parameter-step-size")144 .short('D')145 .takes_value(true)146 .action(ArgAction::StoreValue)147 .value_names(&["DELTA"])148 .requires("parameter-scan")149 .help(150 "This argument requires --parameter-scan to be specified as well. \
6 unmodified lines
157 Arg::new("parameter-list")158 .long("parameter-list")159 .short('L')160 .takes_value(true)161 .action(ArgAction::StoreValue)162 .multiple_occurrences(true)163 .allow_hyphen_values(true)164 .value_names(&["VAR", "VALUES"])165 .conflicts_with_all(&["parameter-scan", "parameter-step-size"])
9 unmodified lines
175 .arg(176 Arg::new("style")177 .long("style")178 .takes_value(true)179 .action(ArgAction::StoreValue)180 .value_name("TYPE")169 .possible_values(&["auto", "basic", "full", "nocolor", "color", "none"])181 .value_parser(["auto", "basic", "full", "nocolor", "color", "none"])182 .help(183 "Set output style type (default: auto). Set this to 'basic' to disable output \184 coloring and interactive elements. Set it to 'full' to enable all effects \185 even if no interactive terminal was detected. Set this to 'nocolor' to \
6 unmodified lines
192 Arg::new("shell")193 .long("shell")194 .short('S')195 .takes_value(true)196 .action(ArgAction::StoreValue)197 .value_name("SHELL")198 .overrides_with("shell")199 .help("Set the shell to use for executing benchmarked commands. This can be the \200 name or the path to the shell executable, or a full command line \
5 unmodified lines
206 )207 .arg(208 Arg::new("no-shell")209 .short('N')210 .action(ArgAction::IncOccurrence)211 .conflicts_with_all(&["shell", "debug-mode"])212 .help("An alias for '--shell=none'.")213 )214 .arg(215 Arg::new("ignore-failure")216 .long("ignore-failure")217 .action(ArgAction::IncOccurrence)218 .short('i')219 .help("Ignore non-zero exit codes of the benchmarked programs."),220 )221 .arg(222 Arg::new("time-unit")223 .long("time-unit")224 .short('u')225 .action(ArgAction::StoreValue)226 .takes_value(true)227 .value_name("UNIT")212 .possible_values(&["millisecond", "second"])228 .value_parser(["millisecond", "second"])229 .help("Set the time unit to be used. Possible values: millisecond, second. \230 If the option is not given, the time unit is determined automatically. \231 This option affects the standard output as well as all export formats except for CSV and JSON."),232 )233 .arg(234 Arg::new("export-asciidoc")235 .long("export-asciidoc")236 .action(ArgAction::StoreValue)237 .takes_value(true)238 .value_name("FILE")239 .help("Export the timing summary statistics as an AsciiDoc table to the given FILE. \240 The output time unit can be changed using the --time-unit option."),241 )242 .arg(243 Arg::new("export-csv")244 .long("export-csv")245 .action(ArgAction::StoreValue)246 .takes_value(true)247 .value_name("FILE")248 .help("Export the timing summary statistics as CSV to the given FILE. If you need \249 the timing results for each individual run, use the JSON export format. \
1 unmodified line
251 )252 .arg(253 Arg::new("export-json")254 .long("export-json")237 .takes_value(true)255 .action(ArgAction::StoreValue)256 .value_name("FILE")257 .help("Export the timing summary statistics and timings of individual runs as JSON to the given FILE. \258 The output time unit is always seconds"),259 )260 .arg(261 Arg::new("export-markdown")262 .long("export-markdown")263 .takes_value(true)264 .action(ArgAction::StoreValue)265 .value_name("FILE")266 .help("Export the timing summary statistics as a Markdown table to the given FILE. \267 The output time unit can be changed using the --time-unit option."),268 )269 .arg(270 Arg::new("export-orgmode")271 .long("export-orgmode")272 .takes_value(true)273 .action(ArgAction::StoreValue)274 .value_name("FILE")275 .help("Export the timing summary statistics as a Emacs org-mode table to the given FILE. \276 The output time unit can be changed using the --time-unit option."),277 )278 .arg(279 Arg::new("show-output")280 .long("show-output")281 .action(ArgAction::SetTrue)282 .conflicts_with("style")283 .help(284 "Print the stdout and stderr of the benchmark instead of suppressing it. \285 This will increase the time it takes for benchmarks to run, \
5 unmodified lines
291 Arg::new("output")292 .long("output")293 .conflicts_with("show-output")294 .takes_value(true)295 .action(ArgAction::StoreValue)296 .value_name("WHERE")297 .help(298 "Control where the output of the benchmark is redirected. <WHERE> can be:\n\n\299 null: Redirect output to /dev/null (the default). \
9 unmodified lines
309 Arg::new("command-name")310 .long("command-name")311 .short('n')312 .takes_value(true)313 .action(ArgAction::StoreValue)314 .multiple_occurrences(true)315 .number_of_values(1)316 .value_name("NAME")317 .help("Give a meaningful name to a command. This can be specified multiple times \
4 unmodified lines
322 .arg(323 Arg::new("min-benchmarking-time")324 .long("min-benchmarking-time")325 .takes_value(true)326 .action(ArgAction::StoreValue)327 .hide(true)328 .help("Set the minimum time (in seconds) to run benchmarks. Note that the number of \329 benchmark runs is additionally influenced by the `--min-runs`, `--max-runs`, and \330 `--runs` option.")331 )332 .arg(333 Arg::new("debug-mode")334 .long("debug-mode")335 .action(ArgAction::IncOccurrence)336 .hide(true)337 .help("Enable debug mode which does not actually run commands, but returns fake times when the command is 'sleep <time>'.")338 )339}
5 unmodified lines
modified:src/command.rs+1 added-1 removed
120 unmodified lines
121 let command_names = matches.values_of("command-name");122 let command_strings = matches.values_of("command").unwrap();123124 if let Some(args) = matches.values_of("parameter-scan") {125 let step_size = matches.value_of("parameter-step-size");125 let step_size = matches.get_one::<String>("parameter-step-size").map(|s| s.as_str());126 Ok(Self(Self::get_parameter_scan_commands(127 command_names,128 command_strings,129 args,
408 unmodified lines
modified:src/options.rs+12 added-12 removed
221 unmodified lines
222 pub fn from_cli_arguments<'a>(matches: &ArgMatches) -> Result<Self, OptionsError<'a>> {223 let mut options = Self::default();224 let param_to_u64 = |param| {225 matches226 .value_of(param)226 .get_one::<String>(param)227 .map(|n| {228 n.parse::<u64>()229 .map_err(|e| OptionsError::IntParsingError(param, e))230 })
28 unmodified lines
259 }260 (None, None) => {}261 };262263 options.setup_command = matches.value_of("setup").map(String::from);263 options.setup_command = matches.get_one::<String>("setup").map(String::from);264265 options.preparation_command = matches266 .values_of("prepare")266 .get_many::<String>("prepare")267 .map(|values| values.map(String::from).collect::<Vec<String>>());268269 options.cleanup_command = matches.value_of("cleanup").map(String::from);269 options.cleanup_command = matches.get_one::<String>("cleanup").map(String::from);270271 options.command_output_policy = if matches.is_present("show-output") {271 options.command_output_policy = if matches.contains_id("show-output") {272 CommandOutputPolicy::Inherit273 } else if let Some(output) = matches.value_of("output") {273 } else if let Some(output) = matches.get_one::<String>("output").map(|s| s.as_str()) {274 match output {275 "null" => CommandOutputPolicy::Null,276 "pipe" => CommandOutputPolicy::Pipe,277 "inherit" => CommandOutputPolicy::Inherit,
8 unmodified lines
286 } else {287 CommandOutputPolicy::Null288 };289290 options.output_style = match matches.value_of("style") {290 options.output_style = match matches.get_one::<String>("style").map(|s| s.as_str()) {291 Some("full") => OutputStyleOption::Full,292 Some("basic") => OutputStyleOption::Basic,293 Some("nocolor") => OutputStyleOption::NoColor,294 Some("color") => OutputStyleOption::Color,
26 unmodified lines
321 }322 OutputStyleOption::Disabled => {}323 };324325 options.executor_kind = if matches.is_present("no-shell") {325 options.executor_kind = if matches.contains_id("no-shell") {326 ExecutorKind::Raw327 } else {328 match (matches.is_present("debug-mode"), matches.value_of("shell")) {328 match (matches.contains_id("debug-mode"), matches.get_one::<String>("shell")) {329 (false, Some(shell)) if shell == "default" => ExecutorKind::Shell(Shell::default()),330 (false, Some(shell)) if shell == "none" => ExecutorKind::Raw,331 (false, Some(shell)) => ExecutorKind::Shell(Shell::parse_from_str(shell)?),332 (false, None) => ExecutorKind::Shell(Shell::default()),
1 unmodified line
334 (true, None) => ExecutorKind::Mock(None),335 }336 };337338 if matches.is_present("ignore-failure") {338 if matches.contains_id("ignore-failure") {339 options.command_failure_action = CmdFailureAction::Ignore;340 }341342 options.time_unit = match matches.value_of("time-unit") {342 options.time_unit = match matches.get_one::<String>("time-unit").map(|s| s.as_str()) {343 Some("millisecond") => Some(Unit::MilliSecond),344 Some("second") => Some(Unit::Second),345 _ => None,346 };347348 if let Some(time) = matches.value_of("min-benchmarking-time") {348 if let Some(time) = matches.get_one::<String>("min-benchmarking-time") {349 options.min_benchmarking_time = time350 .parse::<f64>()351 .map_err(|e| OptionsError::FloatParsingError("min-benchmarking-time", e))?;352 }
61 unmodified lines