Skip to content

Commit 62b8c05

Browse files
committed
add complection for builting --hyperlink-formats
The goal is to make the completion for `rg --hyperlink-format <TAB>` work in the fish shell. These are not exhaustive (the user can also specify custom formats). If this ever makes a difference, perhaps `fn doc_choices_are_exhaustive(&self) -> bool` can be added to the `Flags` trait. The `grep+` value necessitated a change to a test. I'm not sure whether there's a good way to generate the choices directly from `hyperlink_aliases.rs` as a `&'static [&'static str]`. The simplest would be to reorganize `hyperlink_aliases.rs` to keep the keys and values in separate arrays, but that would be less readable.
1 parent 3b7fd44 commit 62b8c05

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

crates/core/flags/defs.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,6 +2953,21 @@ https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
29532953
"#
29542954
}
29552955

2956+
fn doc_choices(&self) -> &'static [&'static str] {
2957+
&[
2958+
"default",
2959+
"none",
2960+
"file",
2961+
"grep+",
2962+
"kitty",
2963+
"macvim",
2964+
"textmate",
2965+
"vscode",
2966+
"vscode-insiders",
2967+
"vscodium",
2968+
]
2969+
}
2970+
29562971
fn update(&self, v: FlagValue, args: &mut LowArgs) -> anyhow::Result<()> {
29572972
let v = v.unwrap_value();
29582973
let string = convert::str(&v)?;
@@ -7665,9 +7680,10 @@ mod tests {
76657680
assert!(
76667681
choice.chars().all(|c| c.is_ascii_alphanumeric()
76677682
|| c == '-'
7668-
|| c == ':'),
7683+
|| c == ':'
7684+
|| c == '+'),
76697685
"choice '{choice}' for flag '{long}' does not match \
7670-
^[-:0-9A-Za-z]+$",
7686+
^[-+:0-9A-Za-z]+$",
76717687
)
76727688
}
76737689
}

0 commit comments

Comments
 (0)