mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 14:30:10 +01:00
refactor: make select index optional
This commit is contained in:
parent
195aa34f95
commit
d7b57f204c
3 changed files with 3 additions and 2 deletions
|
|
@ -210,7 +210,7 @@ pub fn select(
|
||||||
unreachable!("Select suggestion does not support range");
|
unreachable!("Select suggestion does not support range");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unreachable!("Select suggestion must have a command index");
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
let selection_list = if suggest.contains('(') {
|
let selection_list = if suggest.contains('(') {
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ pub fn select(suggest: &mut String, select_list: &mut Vec<TokenStream2>) {
|
||||||
unreachable!("Select suggestion does not support range");
|
unreachable!("Select suggestion does not support range");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unreachable!("Select suggestion must have a command index");
|
quote! {0}
|
||||||
};
|
};
|
||||||
let selection_list = if suggest.contains('(') {
|
let selection_list = if suggest.contains('(') {
|
||||||
let split = suggest[args.to_owned()]
|
let split = suggest[args.to_owned()]
|
||||||
|
|
|
||||||
1
rules.md
1
rules.md
|
|
@ -58,6 +58,7 @@ The placeholder is evaluated as following:
|
||||||
- `{{command[2:5]}}`: The second to fifth arguments. If any of the side is not specified, then it defaults to the start (if it is left) or the end (if it is right).
|
- `{{command[2:5]}}`: The second to fifth arguments. If any of the side is not specified, then it defaults to the start (if it is left) or the end (if it is right).
|
||||||
- `{{typo[2](fix1, fix2)}}`: This will try to change the second argument to candidates in the parenthesis. The argument in parentheses must have at least 2 values. Single arguments are reserved for specific matches, for instance, `path` to search all commands found in the `$PATH` environment, or the `{{shell}}` placeholder, among others.
|
- `{{typo[2](fix1, fix2)}}`: This will try to change the second argument to candidates in the parenthesis. The argument in parentheses must have at least 2 values. Single arguments are reserved for specific matches, for instance, `path` to search all commands found in the `$PATH` environment, or the `{{shell}}` placeholder, among others.
|
||||||
- `{{select[3][selection1, selection2]}}`: A derivative of `typo` placeholder. Will create a suggestion for each selection in the parenthesis. The argument in parentheses also must have at least 2 values. Single arguments are reserved for specific selections, for instance, `path` to search all commands found in the `$PATH` environment with the minimum linguistic distance, or the `{{shell}}` placeholder.
|
- `{{select[3][selection1, selection2]}}`: A derivative of `typo` placeholder. Will create a suggestion for each selection in the parenthesis. The argument in parentheses also must have at least 2 values. Single arguments are reserved for specific selections, for instance, `path` to search all commands found in the `$PATH` environment with the minimum linguistic distance, or the `{{shell}}` placeholder.
|
||||||
|
- Index is optional as it only has effect when using with `path`, and defaults to 0.
|
||||||
- `{{opt::<Regular Expression>}}`: Optional patterns captured in the command with RegEx ([see regex crate for syntax](https://docs.rs/regex-lite/latest/regex_lite/#syntax)). Note that all patterns matching this placeholder will be removed from indexing.
|
- `{{opt::<Regular Expression>}}`: Optional patterns captured in the command with RegEx ([see regex crate for syntax](https://docs.rs/regex-lite/latest/regex_lite/#syntax)). Note that all patterns matching this placeholder will be removed from indexing.
|
||||||
- `{{cmd::<Regular Expression>}}`: Get the matching captures from the last command. Unlike `{{opt}}`, this won't remove the string after matching
|
- `{{cmd::<Regular Expression>}}`: Get the matching captures from the last command. Unlike `{{opt}}`, this won't remove the string after matching
|
||||||
- `{{err::<Regular Expression}}`: Get the matching captures from the error message.
|
- `{{err::<Regular Expression}}`: Get the matching captures from the error message.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue