-
Notifications
You must be signed in to change notification settings - Fork 391
jq: completion does not complete files when it should #510
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
Comments
I don't think it should. At that point we're completing a filter, and nothing happening is intentional for that. From my man page:
$ jq --slurp test.json
jq: error: test/0 is not defined at <top-level>, line 1:
test.json
jq: 1 compile error
$ jq test.json
jq: error: test/0 is not defined at <top-level>, line 1:
test.json
jq: 1 compile error My jq is 1.5 on Ubuntu 18.04. |
Thanks for the analysis, @scop. I had a look at my command line history to try to find the command that made me think I had found a bug, but I can't. Closing. |
No problem, thanks for double checking. I had a peek at jq 1.6 too, and it seems it does have some new usage patterns we should adjust to though, #511 |
The current completion code tries to force the user to use a "mode" argument first, such as
--slurp
, by counting arguments, and only completing files when there are two or more arguments (including the command itself). However, the code as it stands does not count any mode arguments, so the number of arguments never exceeds 1 unless you manually type a file argument, so file arguments are never auto-completed.Example session:
I had a look at the manual of jq to determine what these mode arguments are, because in theory adding a list of them as the third argument to
_count_args
would make the code work.However, the concept of "mode" does not seem to exist in the manual. Indeed, no such argument is required. (You can run jq quite happily without any command-line option.)
So, I propose simply deleting the args-counting code, specifically this bit:
I am happy to make a PR if this is acceptable.
The text was updated successfully, but these errors were encountered: