-
Notifications
You must be signed in to change notification settings - Fork 391
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
Conversation
98def34
to
f423657
Compare
Thanks! Options commit pushed as be4e155 For the other parts, we could brush up a crystal ball and try to figure out if the jq being used does output a "complete enough" listing of its options with |
How about |
Maybe. Or if we predict they might not repeat --help in --help output, maybe --version. |
@scop your guess is as good as mine! But it would be weird not to include |
Cool. Would you mind revising this to implement the fallback behavior? --help works as the canary for me too. |
Sure, I can do that. |
Apologies for my slowness, I have been very busy, and just now that includes using I found that there's a serious problem with the completion as it stands. It tries to force the user to use a "mode" argument first, such as 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 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 can still implement the |
No problem wrt slowness. My time for bash-completion is spotty, too. But I don't quite follow the suggestion, could you elaborate it with a literal example what doesn't work? I also think that's a separate issue from the original one, and would be better off handled in a separate issue if there is one. Anyway, as a counterexample, if I delete the code you suggested, |
@scop, I"ve updated my PR with the |
Thanks very much for your patience and detailed feedback, @scop; as you can see, I'm not fluent programming in bash! I hope I've dealt with all your feedback… |
The options are not all listed by --help, so look in the man page to find a nearly complete list (I hope!). Neither the man page nor --help mentions --help or --version; I have not looked elsewhere to see if there might be yet more. Guard against the possibility of jq being fixed in future by testing to see if its --help output contains “--help” and using it if so, otherwise, use the hard-coded list; see jqlang/jq#2284
I took the liberty to do some line wrapping changes, removed duplicated --version, fixed s/--compact-input/--compact-output/, and removed some superfluous quotes (shfmt -s is our friend). Thanks! |
Thanks for the polish and applying the PR; I've installed |
And good spot with the typo! |
Re shfmt, I suggest installing pre-commit if you wish to run all pre-commit checks configured for the project. CI also runs them, but is badly broken for other reasons at the moment. |
Thanks for the tip! |
The options are not all listed by --help, so look in the man page to find a
nearly complete list (I hope!). Neither the man page nor --help mentions --help
or --version; I have not looked elsewhere to see if there might be yet more.
The treatment of -f|--from-file was incorrect: that option’s argument is the
filter, so the argument should be counted towards the total number of arguments
so far. Hence, remove --from-file from the list of options whose argument is
counted as an option.