Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clap::ValueHint to fix zsh completion #717

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::ffi::OsString;

use clap::{
builder::NonEmptyStringValueParser, crate_version, Arg, ArgAction, ArgMatches, Command,
ValueHint,
};

pub fn get_cli_arguments<'a, I, T>(args: I) -> ArgMatches
Expand Down Expand Up @@ -31,6 +32,7 @@ fn build_command() -> Command {
comparison of the respective runtimes.")
.required(true)
.action(ArgAction::Append)
.value_hint(ValueHint::CommandString)
.value_parser(NonEmptyStringValueParser::new()),
)
.arg(
Expand Down Expand Up @@ -76,6 +78,7 @@ fn build_command() -> Command {
.short('s')
.action(ArgAction::Set)
.value_name("CMD")
.value_hint(ValueHint::CommandString)
.help(
"Execute CMD before each set of timing runs. This is useful for \
compiling your software with the provided parameters, or to do any \
Expand All @@ -90,6 +93,7 @@ fn build_command() -> Command {
.action(ArgAction::Append)
.num_args(1)
.value_name("CMD")
.value_hint(ValueHint::CommandString)
.help(
"Execute CMD before each timing run. This is useful for \
clearing disk caches, for example.\nThe --prepare option can \
Expand All @@ -104,6 +108,7 @@ fn build_command() -> Command {
.short('c')
.action(ArgAction::Set)
.value_name("CMD")
.value_hint(ValueHint::CommandString)
.help(
"Execute CMD after the completion of all benchmarking \
runs for each individual command to be benchmarked. \
Expand Down Expand Up @@ -167,6 +172,7 @@ fn build_command() -> Command {
.action(ArgAction::Set)
.value_name("SHELL")
.overrides_with("shell")
.value_hint(ValueHint::CommandString)
.help("Set the shell to use for executing benchmarked commands. This can be the \
name or the path to the shell executable, or a full command line \
like \"bash --norc\". It can also be set to \"default\" to explicitly select \
Expand Down Expand Up @@ -237,6 +243,7 @@ fn build_command() -> Command {
.long("export-asciidoc")
.action(ArgAction::Set)
.value_name("FILE")
.value_hint(ValueHint::FilePath)
.help("Export the timing summary statistics as an AsciiDoc table to the given FILE. \
The output time unit can be changed using the --time-unit option."),
)
Expand All @@ -245,6 +252,7 @@ fn build_command() -> Command {
.long("export-csv")
.action(ArgAction::Set)
.value_name("FILE")
.value_hint(ValueHint::FilePath)
.help("Export the timing summary statistics as CSV to the given FILE. If you need \
the timing results for each individual run, use the JSON export format. \
The output time unit is always seconds."),
Expand All @@ -254,6 +262,7 @@ fn build_command() -> Command {
.long("export-json")
.action(ArgAction::Set)
.value_name("FILE")
.value_hint(ValueHint::FilePath)
.help("Export the timing summary statistics and timings of individual runs as JSON to the given FILE. \
The output time unit is always seconds"),
)
Expand All @@ -262,6 +271,7 @@ fn build_command() -> Command {
.long("export-markdown")
.action(ArgAction::Set)
.value_name("FILE")
.value_hint(ValueHint::FilePath)
.help("Export the timing summary statistics as a Markdown table to the given FILE. \
The output time unit can be changed using the --time-unit option."),
)
Expand All @@ -270,6 +280,7 @@ fn build_command() -> Command {
.long("export-orgmode")
.action(ArgAction::Set)
.value_name("FILE")
.value_hint(ValueHint::FilePath)
.help("Export the timing summary statistics as an Emacs org-mode table to the given FILE. \
The output time unit can be changed using the --time-unit option."),
)
Expand Down