Skip to content
Myr

Document $ARGS and friends

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Nicolas Williams · committed by Nicolas Williams · parent 66fb962 · Browse files · 2 files+28 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+28 added−0 removed

  • other:+28 added−0 removed

2 files+28 added−0 removed

modified:docs/content/3.manual/manual.yml+13 added
215 unmodified lines
216 available in the program and has the value `"bar"`. Note that217 `value` will be treated as a string, so `--arg foo 123` will218 bind `$foo` to `"123"`.219220 Named arguments are also available to the jq program as221 `$ARGS.named`.222223 * `--argjson name JSON-text`:224225 This option passes a JSON-encoded value to the jq program as a226 predefined variable. If you run jq with `--argjson foo 123`, then
14 unmodified lines
241 (This option is like `--slurpfile`, but when the file has just242 one text, then that is used, else an array of texts is used as243 in `--slurpfile`.)244245 * `--args`:246247 Remaining arguments are positional string arguments. These are248 available to the jq program as `$ARGS.positional[]`.249250 * `--jsonargs`:251252 Remaining arguments are positional JSON text arguments. These253 are available to the jq program as `$ARGS.positional[]`.254255 * `--run-tests [filename]`:256257 Runs the tests in the given file or standard input. This must258 be the last option given and does not honor all preceding
2886 unmodified lines
modified:jq.1.prebuilt+15 added
157 unmodified lines
158.159.IP160This option passes a value to the jq program as a predefined variable\. If you run jq with \fB\-\-arg foo bar\fR, then \fB$foo\fR is available in the program and has the value \fB"bar"\fR\. Note that \fBvalue\fR will be treated as a string, so \fB\-\-arg foo 123\fR will bind \fB$foo\fR to \fB"123"\fR\.161.162.IP163Named arguments are also available to the jq program as \fB$ARGS\.named\fR\.164.165.IP "\(bu" 4166\fB\-\-argjson name JSON\-text\fR:167.168.IP
14 unmodified lines
183.IP184(This option is like \fB\-\-slurpfile\fR, but when the file has just one text, then that is used, else an array of texts is used as in \fB\-\-slurpfile\fR\.)185.186.IP "\(bu" 4187\fB\-\-args\fR:188.189.IP190Remaining arguments are positional string arguments\. These are available to the jq program as \fB$ARGS\.positional[]\fR\.191.192.IP "\(bu" 4193\fB\-\-jsonargs\fR:194.195.IP196Remaining arguments are positional JSON text arguments\. These are available to the jq program as \fB$ARGS\.positional[]\fR\.197.198.IP "\(bu" 4199\fB\-\-run\-tests [filename]\fR:200.201.IP202Runs the tests in the given file or standard input\. This must be the last option given and does not honor all preceding options\. The input consists of comment lines, empty lines, and program lines followed by one input line, as many lines of output as are expected (one per output), and a terminating empty line\. Compilation failure tests start with a line containing only "%%FAIL", then a line containing the program to compile, then a line containing an error message to compare to the actual\.
3141 unmodified lines