Skip to content

Commit

Permalink
cli: Move help/0 to inter.jq, better help for -n
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Sep 12, 2021
1 parent 5a82224 commit e2ff2a2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@
"tfhd",
"tfra",
"tmpl",
"toboolean",
"tobytes",
"toimage",
"tojson",
"tojvalue",
Expand Down
2 changes: 1 addition & 1 deletion doc/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Usage: fq [OPTIONS] [--] [EXPR] [FILE...]
--help,-h Show help
--include-path,-L PATH Include search path
--join-output,-j No newline between outputs
--null-input,-n Null input (can still use input/0 and inputs/0)
--null-input,-n Null input (use input/0 and inputs/0 to read input)
--null-output,-0 Null byte between outputs
--option,-o KEY=VALUE Set option, eg: color=true
addrbase=16
Expand Down
7 changes: 0 additions & 7 deletions pkg/interp/funcs.jq
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# TODO: introspect and show doc, reflection somehow?
def help:
( builtins[]
, "^C interrupt"
, "^D exit REPL"
) | println;

def format: ._format? // null;

# integer division
Expand Down
8 changes: 7 additions & 1 deletion pkg/interp/interp.jq
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,12 @@ def var($k; f):
);
def var($k): . as $c | var($k; $c);

# TODO: introspect and show doc, reflection somehow?
def help:
( builtins[]
, "^C interrupt"
, "^D exit REPL"
) | println;

def _main:
def _formats_list:
Expand Down Expand Up @@ -413,7 +419,7 @@ def _main:
"null_input": {
short: "-n",
long: "--null-input",
description: "Null input (can still use input/0 and inputs/0)",
description: "Null input (use input/0 and inputs/0 to read input)",
bool: true
},
"options": {
Expand Down
7 changes: 6 additions & 1 deletion pkg/interp/testdata/args.fqtest
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/test.mp3:
$ fq
\
exitcode: 2
stderr:
Usage: fq [OPTIONS] [--] [EXPR] [FILE...]
Expand All @@ -16,7 +17,7 @@ Usage: fq [OPTIONS] [--] [EXPR] [FILE...]
--help,-h Show help
--include-path,-L PATH Include search path
--join-output,-j No newline between outputs
--null-input,-n Null input (can still use input/0 and inputs/0)
--null-input,-n Null input (use input/0 and inputs/0 to read input)
--null-output,-0 Null byte between outputs
--option,-o KEY=VALUE Set option, eg: color=true
addrbase=16
Expand Down Expand Up @@ -49,6 +50,7 @@ null> ^D
$ fq -i . /test.mp3
mp3> ^D
$ fq -n
\
exitcode: 2
stderr:
Usage: fq [OPTIONS] [--] [EXPR] [FILE...]
Expand Down Expand Up @@ -129,14 +131,17 @@ wav WAV file
webp WebP image
xing Xing header
$ fq -X
\
exitcode: 2
stderr:
error: -X: no such argument
$ fq --X
\
exitcode: 2
stderr:
error: --X: no such argument
$ fq -.
\
exitcode: 2
stderr:
error: -.: no such argument

0 comments on commit e2ff2a2

Please sign in to comment.