mirror of
https://github.com/denisidoro/navi
synced 2024-11-22 11:33:10 +00:00
Make --allow-extra default (#281)
This commit is contained in:
parent
6e582e4015
commit
b49ee6a491
2 changed files with 11 additions and 9 deletions
10
README.md
10
README.md
|
@ -177,6 +177,8 @@ Variable names should only include alphanumeric characters and `_`.
|
|||
|
||||
If there's a corresponding line starting with `$` for a variable, suggestions will be displayed. Otherwise, the user will be able to type any value for it.
|
||||
|
||||
If you hit `<tab>` the query typed will be prefered. If you hit `<enter>` the selection will be prefered.
|
||||
|
||||
### Advanced variable options
|
||||
|
||||
For lines starting with `$` you can add use `---` to customize the behavior of `fzf` or how the value is going to be used:
|
||||
|
@ -189,10 +191,10 @@ $ image_id: docker images --- --column 3 --header-lines 1 --delimiter '\s\s+'
|
|||
```
|
||||
|
||||
The supported parameters are:
|
||||
- `--allow-extra` *(experimental)*: handles `fzf` option `--print-query`. `enter` will prefer a selection and `tab` will prefer the query typed.
|
||||
- `--multi` : forwarded option to `fzf`.
|
||||
- `--header-lines` : forwarded option to `fzf`
|
||||
- `--column` : forwarded option to `fzf`.
|
||||
- `--prevent-extra` *(experimental)*: limits the user to select one of the suggestions;
|
||||
- `--multi` : forwarded option to `fzf`;
|
||||
- `--header-lines` : forwarded option to `fzf`;
|
||||
- `--column` : forwarded option to `fzf`;
|
||||
- `--delimiter` : forwarded option to `fzf`.
|
||||
|
||||
### Variable dependency
|
||||
|
|
10
src/cheat.rs
10
src/cheat.rs
|
@ -39,7 +39,7 @@ fn parse_opts(text: &str) -> SuggestionOpts {
|
|||
let mut header_lines: u8 = 0;
|
||||
let mut column: Option<u8> = None;
|
||||
let mut multi = false;
|
||||
let mut allow_extra = false;
|
||||
let mut prevent_extra = false;
|
||||
let mut delimiter: Option<String> = None;
|
||||
|
||||
let mut parts = text.split(' ');
|
||||
|
@ -47,7 +47,7 @@ fn parse_opts(text: &str) -> SuggestionOpts {
|
|||
while let Some(p) = parts.next() {
|
||||
match p {
|
||||
"--multi" => multi = true,
|
||||
"--allow-extra" => allow_extra = true,
|
||||
"--prevent-extra" => prevent_extra = true,
|
||||
"--header" | "--headers" | "--header-lines" => {
|
||||
header_lines = remove_quotes(parts.next().unwrap()).parse::<u8>().unwrap()
|
||||
}
|
||||
|
@ -63,10 +63,10 @@ fn parse_opts(text: &str) -> SuggestionOpts {
|
|||
header_lines,
|
||||
column,
|
||||
delimiter,
|
||||
suggestion_type: match (multi, allow_extra) {
|
||||
suggestion_type: match (multi, prevent_extra) {
|
||||
(true, _) => SuggestionType::MultipleSelections, // multi wins over allow-extra
|
||||
(false, true) => SuggestionType::SingleRecommendation,
|
||||
(false, false) => SuggestionType::SingleSelection,
|
||||
(false, false) => SuggestionType::SingleRecommendation,
|
||||
(false, true) => SuggestionType::SingleSelection,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue