mirror of
https://github.com/denisidoro/navi
synced 2024-11-14 15:57:13 +00:00
pull request comments
This commit is contained in:
parent
3617126f6a
commit
0d22fe49ab
4 changed files with 8 additions and 12 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,5 +1,2 @@
|
|||
/target
|
||||
**/*.rs.bk
|
||||
|
||||
# intellij
|
||||
.idea
|
||||
|
|
|
@ -177,10 +177,10 @@ $ y: echo -e "$((x+10))\n$((x+20))"
|
|||
### Variable options
|
||||
|
||||
For lines starting with `$` you can add use`---` to parse parameters to `fzf`.
|
||||
* `--allow-extra` : handles `fzf` option `--print-query`. `enter` will prefer a selection,
|
||||
`tab` will prefer the query typed.
|
||||
* `--allow-extra` *(experimental)*: handles `fzf` option `--print-query`. `enter` will prefer a selection,
|
||||
`tab` will prefer the query typed.
|
||||
* `--multi` : forwarded option to `fzf`.
|
||||
* `--header` | `--headers` | `--header-lines` : forwarded option to `fzf`
|
||||
* `--header-lines` : forwarded option to `fzf`
|
||||
* `--column` : forwarded option to `fzf`.
|
||||
* `--delimiter` : forwarded option to `fzf`.
|
||||
|
||||
|
|
|
@ -82,9 +82,8 @@ fn parse_variable_line(line: &str) -> (&str, &str, Option<SuggestionOpts>) {
|
|||
let caps = re.captures(line).unwrap();
|
||||
let variable = caps.get(1).unwrap().as_str().trim();
|
||||
let mut command_plus_opts = caps.get(2).unwrap().as_str().split("---");
|
||||
let command: &str = command_plus_opts.next().unwrap();
|
||||
let command_option_string: Option<&str> = command_plus_opts.next();
|
||||
let command_options = command_option_string.map(parse_opts);
|
||||
let command = command_plus_opts.next().unwrap();
|
||||
let command_options = command_plus_opts.next().map(parse_opts);
|
||||
(variable, command, command_options)
|
||||
}
|
||||
|
||||
|
@ -217,7 +216,7 @@ mod tests {
|
|||
result.insert(
|
||||
"ssh;user".to_string(),
|
||||
(
|
||||
" echo -e \"$(whoami)\\nroot\" ".to_string(),
|
||||
r#" echo -e "$(whoami)\nroot" "#.to_string(),
|
||||
Some(SuggestionOpts {
|
||||
header_lines: 0,
|
||||
column: None,
|
||||
|
|
|
@ -176,11 +176,11 @@ fn replace_variables_from_snippet(
|
|||
pub fn main(variant: Variant, config: Config, contains_key: bool) -> Result<(), Box<dyn Error>> {
|
||||
let _ = display::WIDTHS;
|
||||
|
||||
let (raw_snippet, variables) = fzf::call(gen_core_fzf_opts(variant, &config), |stdin| {
|
||||
let (raw_selection, variables) = fzf::call(gen_core_fzf_opts(variant, &config), |stdin| {
|
||||
Some(cheat::read_all(&config, stdin))
|
||||
});
|
||||
|
||||
let (key, tags, snippet) = extract_from_selections(&raw_snippet[..], contains_key);
|
||||
let (key, tags, snippet) = extract_from_selections(&raw_selection[..], contains_key);
|
||||
let interpolated_snippet =
|
||||
replace_variables_from_snippet(snippet, tags, variables.unwrap(), &config);
|
||||
|
||||
|
|
Loading…
Reference in a new issue