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

Refactor completion function #560

Merged
merged 2 commits into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions ci/test_complete.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/sh

##
# Compares options in `rg --help` output to options in zsh completion function
#
# @todo If we could rely on zsh being installed we could change all of this to
# simply source the completion-function file and pull the rg_args array out...
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like you could probably install zsh in the Travis CI config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, i wasn't sure it was an option. Knowing that it is, i'll probably do that the next time i need to make changes to the function.


set -e

Expand Down Expand Up @@ -32,7 +36,8 @@ main() {
# 'Parse' options out of the completion-function file. To prevent false
# negatives, we:
#
# * Exclude lines that look like comments
# * Exclude lines that don't start with punctuation expected of option
# definitions
# * Exclude lines that don't appear to have a bracketed description
# suitable for `_arguments`
# * Exclude those bracketed descriptions so we don't match options
Expand All @@ -48,8 +53,11 @@ main() {
# variables or command substitutions. Brace expansion is OK as long as
# each component of the expression is a complete option flag — in
# other words, `{--foo,--bar}` is valid, but `--{foo,bar}` is not
"${rg}" -v -- '^\s*#' "${_rg}" |
"${rg}" --replace '$1' -- '^.*?(?:\(.+?\).*?)?(-.+)\[.+\].*' |
# * Bracketed descriptions must contain at least two characters and must
# not begin with `!`, `@`, or `^` (in order to avoid confusion with
# shell syntax)
"${rg}" -- "^\s*[\"':({*-]" "${_rg}" |
"${rg}" --replace '$1' -- '^.*?(?:\(.+?\).*?)?(-.+)\[[^!@^].+\].*' |
tr -d "\t (){}*=+:'\"" |
tr ',' '\n' |
sort -u > "${compTemp}"
Expand Down
Loading