feat(jq): support external-argument flags (--arg, --argjson, --rawfile, --slurpfile, --args, --jsonargs)#291
feat(jq): support external-argument flags (--arg, --argjson, --rawfile, --slurpfile, --args, --jsonargs)#291trieloff wants to merge 6 commits into
Conversation
Agent-Id: agent-adffc8b9-56e7-42e1-9640-29e54e91cb68 Linked-Note-Id: 5eacc9eb-3c60-4792-a92f-e032866df682
Signed-off-by: Lars Trieloff <lars@trieloff.net>
Agent-Id: agent-5e21eaf1-efeb-4038-8f3b-ee7539cebc9a Linked-Note-Id: 704d1169-b7c6-4f47-b565-d020c66a30ea
Signed-off-by: Lars Trieloff <lars@trieloff.net>
|
@trieloff is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
|
Note on prior art: this PR builds on the approach in #162 (feat(jq): add --arg and --argjson flags by @pawaca), which first introduced --arg / --argjson by seeding the query engine variable map. Credit to that PR for the original direction and the maintainer feedback there. This PR supersedes #162 by extending it to the full external-argument family:
If this lands, #162 can be closed as superseded. |
Signed-off-by: Lars Trieloff <lars@trieloff.net>
0a6fc7b to
60fffdc
Compare
There was a problem hiding this comment.
Pull request overview
Adds full jq external-argument support to the jq command implementation, wiring named and positional arguments through the query engine so filters can access $NAME bindings and $ARGS.{named,positional} in a way that matches jq CLI behavior.
Changes:
- Implemented parsing for
--arg,--argjson,--rawfile,--slurpfile,--args, and--jsonargsinjq.ts, including file-backed bindings via the shared file reader. - Plumbed
namedArgs/positionalArgsinto the evaluator context and implemented$ARGSresolution with null-prototype objects plus unsafe-key filtering. - Added unit tests and real-bash comparison tests + recorded fixtures for the new flags.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/just-bash/src/comparison-tests/jq-args-positional.comparison.test.ts | Adds real-bash comparison coverage for --args / --jsonargs behaviors. |
| packages/just-bash/src/comparison-tests/jq-arg.comparison.test.ts | Adds real-bash comparison coverage for named-argument flags and $ARGS. |
| packages/just-bash/src/comparison-tests/fixtures/jq-args-positional.comparison.fixtures.json | Recorded outputs for positional-argument comparison tests. |
| packages/just-bash/src/comparison-tests/fixtures/jq-arg.comparison.fixtures.json | Recorded outputs for named-argument comparison tests. |
| packages/just-bash/src/commands/query-engine/evaluator.ts | Threads named/positional args through EvalContext and implements $ARGS VarRef behavior. |
| packages/just-bash/src/commands/jq/jq.ts | Implements CLI parsing + semantics for jq external-argument flags and passes them into evaluation. |
| packages/just-bash/src/commands/jq/jq.args-positional.test.ts | Adds unit tests for positional-argument flags and combinations. |
| packages/just-bash/src/commands/jq/jq.arg.test.ts | Adds unit tests for named-argument flags, $ARGS, error cases, and safety coverage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Lars Trieloff <lars@trieloff.net>
|
Please add a changeset |
Adds faithful support for jq's entire external-argument family, verified against real jq 1.7.1-apple.
What
Named-argument flags bind a variable and populate $ARGS.named:
Positional-argument flags populate $ARGS.positional:
How
Testing
Known minor deviations (non-blocking)