Skip to content

feat(jq): add support for all options, and fix --from-file #507

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

Merged
merged 1 commit into from
Mar 28, 2021
Merged
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
20 changes: 19 additions & 1 deletion completions/jq
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,25 @@ _jq()
esac

if [[ $cur == -* ]]; then
COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
# Get jq's --help output and see whether it mentions --help
# jq's --help only shows some of its command-line options; some are not
# even listed in the man page!
local help_output=$("$1" --help 2>/dev/null)

if [[ $help_output == *--help* ]]; then
# If the output of --help seems complete, use it
COMPREPLY=($(compgen -W \
'$(printf "%s" "$help_output" | _parse_help -)' -- "$cur"))
else
# Otherwise, use a hard-coded list of known flags, some of which do
# not appear in the output of --help as of jq 1.6.
COMPREPLY=($(compgen -W '--version --seq --stream --slurp
--raw-input --null-input --compact-output --tab --indent
--color-output -monochrome-output --ascii-output --unbuffered
--sort-keys --raw-output --join-output --from-file --exit-status
--arg --argjson --slurpfile --rawfile --argfile --args
--jsonargs --run-tests --help' -- "$cur"))
fi
return
fi

Expand Down