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

Support --args. #224

Merged
merged 4 commits into from
Nov 8, 2024
Merged

Support --args. #224

merged 4 commits into from
Nov 8, 2024

Conversation

01mf02
Copy link
Owner

@01mf02 01mf02 commented Nov 7, 2024

This PR implements support for the --args command-line flag.
It collects all arguments after --args except the first occurrence of -- into $ARGS.positional.

Differences with respect to jq:

  • jq -nc '$ARGS.positional' --args --foo yields an error, because it considers --foo as a flag, whereas jaq outputs ["--foo"]. However, jq -cn '$ARGS.positional' --args -- --foo yields ["--foo"] for both jq and jaq.
  • jq -cn --args '$ARGS.positional' a yields ["a"], whereas jaq yields null.

To invoke jq in a way that is compatible with jaq:

  • Always give a filter before --args (or use -f).
  • Use --args -- if any argument after --args might start with --.

@01mf02 01mf02 mentioned this pull request Nov 7, 2024
@01mf02 01mf02 merged commit f338aeb into main Nov 8, 2024
1 check passed
@01mf02 01mf02 deleted the args branch November 8, 2024 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant