Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"invalid option definition" in ripgrep Zsh completion #771

Closed
lilianmoraru opened this issue Dec 8, 2016 · 4 comments
Closed

"invalid option definition" in ripgrep Zsh completion #771

lilianmoraru opened this issue Dec 8, 2016 · 4 comments
Labels
A-completion Area: completion generator C-bug Category: Updating dependencies

Comments

@lilianmoraru
Copy link

Rust Version

  • rustc 1.15.0-nightly (daf8c1dfc 2016-12-05)

Affected Version of clap

  • 2.19.1

Expected Behavior Summary

To see the completion

Actual Behavior Summary

ripgrep v0.3.2

ripgrep's zsh completion does not work and executing completion for rg -- throws these messages(note: I tried rustup too and it worked):

_arguments:comparguments:312: invalid option definition: --color+[When to use color. [default: auto]]: :(never auto always ansi)
_arguments:comparguments:312: invalid option definition: --color+[When to use color. [default: auto]]: :(never auto always ansi)
_arguments:comparguments:312: invalid option definition: --color+[When to use color. [default: auto]]: :(never auto always ansi)
_arguments:comparguments:312: invalid option definition: --color+[When to use color. [default: auto]]: :(never auto always ansi)
_arguments:comparguments:312: invalid option definition: --color+[When to use color. [default: auto]]: :(never auto always ansi)

I cannot create a gist(company proxy) so I will put here the generated completion:

#compdef rg

_rg() {
	typeset -A opt_args
	local ret=1

	local context curcontext="$curcontext" state line
    _arguments -s -S -C \
"*-e+[A regular expression used for searching.]" \
"*--regexp+[A regular expression used for searching.]" \
"--color+[When to use color. [default: auto]]: :(never auto always ansi)" \
"*--colors+[Configure color settings and styles.]" \
"*-g+[Include or exclude files/directories.]" \
"*--glob+[Include or exclude files/directories.]" \
"*-t+[Only search files matching TYPE.]" \
"*--type+[Only search files matching TYPE.]" \
"*-T+[Do not search files matching TYPE.]" \
"*--type-not+[Do not search files matching TYPE.]" \
"-A+[Show NUM lines after each match.]" \
"--after-context+[Show NUM lines after each match.]" \
"-B+[Show NUM lines before each match.]" \
"--before-context+[Show NUM lines before each match.]" \
"-C+[Show NUM lines before and after each match.]" \
"--context+[Show NUM lines before and after each match.]" \
"--context-separator+[Set the context separator string. [default: --]]" \
"*-f+[Search for patterns from the given file.]" \
"*--file+[Search for patterns from the given file.]" \
"*--ignore-file+[Specify additional ignore files.]" \
"-m+[Limit the number of matches.]" \
"--max-count+[Limit the number of matches.]" \
"--maxdepth+[Descend at most NUM directories.]" \
"-r+[Replace matches with string given.]" \
"--replace+[Replace matches with string given.]" \
"-j+[The approximate number of threads to use.]" \
"--threads+[The approximate number of threads to use.]" \
"*--type-add+[Add a new glob for a file type.]" \
"*--type-clear+[Clear globs for given file type.]" \
"-h[Show short help output.]" \
"--help[Show verbose help output.]" \
"-V[Prints version information.]" \
"--version[Prints version information.]" \
"(-f --file -e --regexp --type-list)--files[Print each file that would be searched.]" \
"(-f --file --files -e --regexp)--type-list[Show all supported file types.]" \
"-a[Search binary files as if they were text.]" \
"--text[Search binary files as if they were text.]" \
"-c[Only show count of matches for each file.]" \
"--count[Only show count of matches for each file.]" \
"-F[Treat the pattern as a literal string.]" \
"--fixed-strings[Treat the pattern as a literal string.]" \
"-i[Case insensitive search.]" \
"--ignore-case[Case insensitive search.]" \
"-n[Show line numbers.]" \
"--line-number[Show line numbers.]" \
"-N[Suppress line numbers.]" \
"--no-line-number[Suppress line numbers.]" \
"-q[Do not print anything to stdout.]" \
"--quiet[Do not print anything to stdout.]" \
"*-u[Reduce the level of "smart" searching.]" \
"*--unrestricted[Reduce the level of "smart" searching.]" \
"-v[Invert matching.]" \
"--invert-match[Invert matching.]" \
"-w[Only show matches surrounded by word boundaries.]" \
"--word-regexp[Only show matches surrounded by word boundaries.]" \
"--column[Show column numbers]" \
"--debug[Show debug messages.]" \
"-l[Only show the path of each file with at least one match.]" \
"--files-with-matches[Only show the path of each file with at least one match.]" \
"--files-without-match[Only show the path of each file that contains zero matches.]" \
"-H[Show file name for each match.]" \
"--with-filename[Show file name for each match.]" \
"--no-filename[Never show the file name for a match.]" \
"--heading[Show matches grouped by each file.]" \
"--no-heading[Don't group matches by each file.]" \
"--hidden[Search hidden files and directories.]" \
"-L[Follow symbolic links.]" \
"--follow[Follow symbolic links.]" \
"--mmap[Searching using memory maps when possible.]" \
"--no-messages[Suppress all error messages.]" \
"--no-mmap[Never use memory maps.]" \
"--no-ignore[Don't respect ignore files.]" \
"--no-ignore-parent[Don't respect ignore files in parent directories.]" \
"--no-ignore-vcs[Don't respect VCS ignore files]" \
"--null[Print NUL byte after file names]" \
"-p[Alias for --color always --heading -n.]" \
"--pretty[Alias for --color always --heading -n.]" \
"-s[Search case sensitively.]" \
"--case-sensitive[Search case sensitively.]" \
"-S[Smart case search.]" \
"--smart-case[Smart case search.]" \
"--vimgrep[Show results in vim compatible format.]" \
"1:: :_rg_commands" \
&& ret=0
    
}

(( $+functions[_rg_commands] )) ||
_rg_commands() {
    local commands; commands=(
        "PATTERN:A regular expression used for searching." \
"PATH:A file or directory to search." \
    )
    _describe -t commands 'rg commands' commands "$@"
}
(( $+functions[_rg_commands] )) ||
_rg_commands() {
    local commands; commands=(
        "PATTERN:A regular expression used for searching." \
"PATH:A file or directory to search." \
    )
    _describe -t commands 'rg commands' commands "$@"
}

_rg "$@"%

Steps to Reproduce the issue

  1. git clone -b 0.3.2 https://github.com/BurntSushi/ripgrep.git
  2. cd ripgrep && cargo build
  3. Example on Ubuntu: sudo cp ./target/debug/build/*/out/_rg /usr/share/zsh/functions/Completion/Linux/
  4. Restart zsh terminal and try to obtain the completion for ripgrep/target/debug/rg --
@kbknapp
Copy link
Member

kbknapp commented Dec 8, 2016

Thanks for taking the time to file all this! I'll look into it tonight and post back here with anything I find.

@kbknapp kbknapp added A-completion Area: completion generator P2: need to have C-bug Category: Updating dependencies labels Dec 8, 2016
@kbknapp
Copy link
Member

kbknapp commented Dec 8, 2016

Actually, looking at this real quick I think it's because in this line:

"--color+[When to use color. [default: auto]]: :(never auto always ansi)" \

the [ and ] in the default value need to be escaped. So this should be an easy fix :)

@kbknapp kbknapp added the D: easy label Dec 8, 2016
@kbknapp
Copy link
Member

kbknapp commented Dec 9, 2016

This is fixed in #772

Once that merges I'll put v2.19.2 on crates.io

@homu homu closed this as completed in 7e17d5a Dec 9, 2016
@lilianmoraru
Copy link
Author

I can confirm that it works now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-completion Area: completion generator C-bug Category: Updating dependencies
Projects
None yet
Development

No branches or pull requests

2 participants