pull request comments

This commit is contained in:
Ingolf Wagner 2020-03-14 23:46:33 +08:00
parent 3617126f6a
commit 0d22fe49ab
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
4 changed files with 8 additions and 12 deletions

3
.gitignore vendored
View file

@ -1,5 +1,2 @@
/target
**/*.rs.bk
# intellij
.idea

View file

@ -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`.

View file

@ -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,

View file

@ -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);