use set and settrue
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 5fcb716 · Browse files · 2 files·+28 added−52 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+28 added−52 removed
- other:+28 added−52 removed
Provenance
- Commit
27ec9e2- Tree
fc7d35a- Author
Benjamin Rombaut <benjamin.rombaut@gmail.com>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
5fcb716
2 files changed+28 added−52 removed
modified:src/cli.rs+24 added-48 removed
34 unmodified lines35 .arg(36 Arg::new("warmup")37 .long("warmup")38 .short('w')39- .takes_value(true)39 .value_name("NUM")41- .action(ArgAction::StoreValue)40+ .action(ArgAction::Set)41 .help(42 "Perform NUM warmup runs before the actual benchmark. This can be used \43 to fill (disk) caches for I/O-heavy programs.",44 ),1 unmodified line46 .arg(47 Arg::new("min-runs")48 .long("min-runs")49 .short('m')51- .takes_value(true)52- .action(ArgAction::StoreValue)50+ .action(ArgAction::Set)51 .value_name("NUM")52 .help("Perform at least NUM runs for each command (default: 10)."),53 )54 .arg(55 Arg::new("max-runs")56 .long("max-runs")57 .short('M')60- .takes_value(true)61- .action(ArgAction::StoreValue)58+ .action(ArgAction::Set)59 .value_name("NUM")60 .help("Perform at most NUM runs for each command. By default, there is no limit."),61 )62 .arg(63 Arg::new("runs")64 .long("runs")65 .conflicts_with_all(&["max-runs", "min-runs"])66 .short('r')70- .takes_value(true)71- .action(ArgAction::StoreValue)67+ .action(ArgAction::Set)68 .value_name("NUM")69 .help("Perform exactly NUM runs for each command. If this option is not specified, \70 hyperfine automatically determines the number of runs."),71 )72 .arg(73 Arg::new("setup")74 .long("setup")75 .short('s')80- .takes_value(true)81- .action(ArgAction::StoreValue)76+ .action(ArgAction::Set)82- .number_of_values(1)77 .value_name("CMD")78 .help(79 "Execute CMD before each set of timing runs. This is useful for \80 compiling your software with the provided parameters, or to do any \4 unmodified lines85 .arg(86 Arg::new("prepare")87 .long("prepare")88 .short('p')95- .takes_value(true)96- .action(ArgAction::StoreValue)89+ .action(ArgAction::Append)97- .multiple_occurrences(true)90 .number_of_values(1)91 .value_name("CMD")92 .help(93 "Execute CMD before each timing run. This is useful for \6 unmodified lines100 .arg(101 Arg::new("cleanup")102 .long("cleanup")103 .short('c')112- .action(ArgAction::StoreValue)113- .takes_value(true)104+ .action(ArgAction::Set)105 .value_name("CMD")106 .help(107 "Execute CMD after the completion of all benchmarking \108 runs for each individual command to be benchmarked. \4 unmodified lines113 .arg(114 Arg::new("parameter-scan")115 .long("parameter-scan")116 .short('P')126- .takes_value(true)127- .action(ArgAction::StoreValue)117+ .action(ArgAction::Set)118 .allow_hyphen_values(true)119 .value_names(&["VAR", "MIN", "MAX"])120 .help(121 "Perform benchmark runs for each value in the range MIN..MAX. Replaces the \9 unmodified lines131 .arg(132 Arg::new("parameter-step-size")133 .long("parameter-step-size")134 .short('D')145- .takes_value(true)146- .action(ArgAction::StoreValue)135+ .action(ArgAction::Set)136 .value_names(&["DELTA"])137 .requires("parameter-scan")138 .help(139 "This argument requires --parameter-scan to be specified as well. \5 unmodified lines145 .arg(146 Arg::new("parameter-list")147 .long("parameter-list")148 .short('L')160- .takes_value(true)161- .action(ArgAction::StoreValue)149+ .action(ArgAction::Append)162- .multiple_occurrences(true)150 .allow_hyphen_values(true)151 .value_names(&["VAR", "VALUES"])152 .conflicts_with_all(&["parameter-scan", "parameter-step-size"])153 .help(7 unmodified lines161 )162 .arg(163 Arg::new("style")164 .long("style")178- .takes_value(true)179- .action(ArgAction::StoreValue)165+ .action(ArgAction::Set)166 .value_name("TYPE")167 .value_parser(["auto", "basic", "full", "nocolor", "color", "none"])168 .help(169 "Set output style type (default: auto). Set this to 'basic' to disable output \7 unmodified lines177 .arg(178 Arg::new("shell")179 .long("shell")180 .short('S')195- .takes_value(true)196- .action(ArgAction::StoreValue)181+ .action(ArgAction::Set)182 .value_name("SHELL")183 .overrides_with("shell")184 .help("Set the shell to use for executing benchmarked commands. This can be the \185 name or the path to the shell executable, or a full command line \5 unmodified lines191 )192 .arg(193 Arg::new("no-shell")194 .short('N')210- .action(ArgAction::IncOccurrence)195+ .action(ArgAction::SetTrue)196 .conflicts_with_all(&["shell", "debug-mode"])197 .help("An alias for '--shell=none'.")198 )199 .arg(200 Arg::new("ignore-failure")201 .long("ignore-failure")217- .action(ArgAction::IncOccurrence)202+ .action(ArgAction::SetTrue)203 .short('i')204 .help("Ignore non-zero exit codes of the benchmarked programs."),205 )206 .arg(207 Arg::new("time-unit")208 .long("time-unit")209 .short('u')225- .action(ArgAction::StoreValue)226- .takes_value(true)210+ .action(ArgAction::Set)211 .value_name("UNIT")212 .value_parser(["millisecond", "second"])213 .help("Set the time unit to be used. Possible values: millisecond, second. \214 If the option is not given, the time unit is determined automatically. \1 unmodified line216 )217 .arg(218 Arg::new("export-asciidoc")219 .long("export-asciidoc")236- .action(ArgAction::StoreValue)237- .takes_value(true)220+ .action(ArgAction::Set)221 .value_name("FILE")222 .help("Export the timing summary statistics as an AsciiDoc table to the given FILE. \223 The output time unit can be changed using the --time-unit option."),224 )225 .arg(226 Arg::new("export-csv")227 .long("export-csv")245- .action(ArgAction::StoreValue)246- .takes_value(true)228+ .action(ArgAction::Set)229 .value_name("FILE")230 .help("Export the timing summary statistics as CSV to the given FILE. If you need \231 the timing results for each individual run, use the JSON export format. \232 The output time unit is always seconds."),233 )234 .arg(235 Arg::new("export-json")236 .long("export-json")255- .action(ArgAction::StoreValue)237+ .action(ArgAction::Set)238 .value_name("FILE")239 .help("Export the timing summary statistics and timings of individual runs as JSON to the given FILE. \240 The output time unit is always seconds"),241 )242 .arg(243 Arg::new("export-markdown")244 .long("export-markdown")263- .takes_value(true)264- .action(ArgAction::StoreValue)245+ .action(ArgAction::Set)246 .value_name("FILE")247 .help("Export the timing summary statistics as a Markdown table to the given FILE. \248 The output time unit can be changed using the --time-unit option."),249 )250 .arg(251 Arg::new("export-orgmode")252 .long("export-orgmode")272- .takes_value(true)273- .action(ArgAction::StoreValue)253+ .action(ArgAction::Set)254 .value_name("FILE")255 .help("Export the timing summary statistics as a Emacs org-mode table to the given FILE. \256 The output time unit can be changed using the --time-unit option."),257 )12 unmodified lines270 .arg(271 Arg::new("output")272 .long("output")273 .conflicts_with("show-output")294- .takes_value(true)295- .action(ArgAction::StoreValue)274+ .action(ArgAction::Set)275 .value_name("WHERE")276 .help(277 "Control where the output of the benchmark is redirected. <WHERE> can be:\n\n\278 null: Redirect output to /dev/null (the default). \8 unmodified lines287 .arg(288 Arg::new("command-name")289 .long("command-name")290 .short('n')312- .takes_value(true)313- .action(ArgAction::StoreValue)291+ .action(ArgAction::Append)314- .multiple_occurrences(true)292 .number_of_values(1)293 .value_name("NAME")294 .help("Give a meaningful name to a command. This can be specified multiple times \295 if several commands are benchmarked."),2 unmodified lines298 // see discussion in https://github.com/sharkdp/hyperfine/issues/527299 .arg(300 Arg::new("min-benchmarking-time")301 .long("min-benchmarking-time")325- .takes_value(true)326- .action(ArgAction::StoreValue)302+ .action(ArgAction::Set)303 .hide(true)304 .help("Set the minimum time (in seconds) to run benchmarks. Note that the number of \305 benchmark runs is additionally influenced by the `--min-runs`, `--max-runs`, and \306 `--runs` option.")307 )308 .arg(309 Arg::new("debug-mode")310 .long("debug-mode")335- .action(ArgAction::IncOccurrence)311+ .action(ArgAction::SetTrue)312 .hide(true)313 .help("Enable debug mode which does not actually run commands, but returns fake times when the command is 'sleep <time>'.")314 )315 }5 unmodified linesmodified:src/options.rs+4 added-4 removed
266 unmodified lines267 .map(|values| values.map(String::from).collect::<Vec<String>>());268 269 options.cleanup_command = matches.get_one::<String>("cleanup").map(String::from);270 271- options.command_output_policy = if matches.contains_id("show-output") {271+ options.command_output_policy = if matches.get_flag("show-output") {272 CommandOutputPolicy::Inherit273 } else if let Some(output) = matches.get_one::<String>("output").map(|s| s.as_str()) {274 match output {275 "null" => CommandOutputPolicy::Null,45 unmodified lines321 }322 OutputStyleOption::Disabled => {}323 };324 325- options.executor_kind = if matches.contains_id("no-shell") {325+ options.executor_kind = if matches.get_flag("no-shell") {326 ExecutorKind::Raw327 } else {328- match (matches.contains_id("debug-mode"), matches.get_one::<String>("shell")) {328+ match (matches.get_flag("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 line334 (true, None) => ExecutorKind::Mock(None),335 }336 };337 338- if matches.contains_id("ignore-failure") {338+ if matches.get_flag("ignore-failure") {339 options.command_failure_action = CmdFailureAction::Ignore;340 }341 342 options.time_unit = match matches.get_one::<String>("time-unit").map(|s| s.as_str()) {71 unmodified lines