Skip to content

Commit

Permalink
cli: Make --raw-string work with input/0 and inputs/0
Browse files Browse the repository at this point in the history
Also lots of refactor
  • Loading branch information
wader committed Sep 12, 2021
1 parent 845bc6b commit ac8cfca
Show file tree
Hide file tree
Showing 10 changed files with 242 additions and 129 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"tfhd",
"tfra",
"tmpl",
"toarray",
"toboolean",
"tobytes",
"toimage",
Expand Down
Binary file modified doc/file.mp3
Binary file not shown.
Binary file modified doc/file.mp4
Binary file not shown.
4 changes: 2 additions & 2 deletions doc/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ For more information see https://github.com/wader/fq

Usage: fq [OPTIONS] [--] [EXPR] [FILE...]
--compact,-c Compact output
--decode,-d NAME Decode format (probe)
--decode,-d NAME Decode format (default probe)
--file,-f PATH Read EXPR from file
--formats Show supported formats
--help,-h Show help
Expand All @@ -18,10 +18,10 @@ Usage: fq [OPTIONS] [--] [EXPR] [FILE...]
--null-output,-0 Null byte between outputs
--option,-o KEY=VALUE Set option, eg: color=true
--options Show all options
--raw-input,-R Read raw input strings (don't decode)
--raw-output,-r Raw string output (without quotes)
--repl,-i Interactive REPL
--slurp,-s Read (slurp) all inputs into an array
--raw-input,-R Read raw input strings (don't decode)
--version,-v Show version (dev)
</pre>

Expand Down
4 changes: 3 additions & 1 deletion pkg/interp/args.jq
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ def args_help_text($opts):
end;
( _maxoptlen as $l
| $opts
| to_entries[]
| to_entries
| sort_by(.value.long)
| .[]
| (.value | .help_default // .default) as $default
| [ "\(.value | _opthelp | rpad(" "; $l)) \(.value.description)"
, if $default then
Expand Down
9 changes: 6 additions & 3 deletions pkg/interp/internal.jq
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ def _default_options(f): _global_var("default_options"; f);
def _options_stack: _global_var("options_stack");
def _options_stack(f): _global_var("options_stack"; f);

def _parsed_args: _global_var("parsed_args");
def _parsed_args(f): _global_var("parsed_args"; f);

def _cli_last_expr_error: _global_var("cli_last_expr_error");
def _cli_last_expr_error(f): _global_var("cli_last_expr_error"; f);

Expand All @@ -41,6 +38,12 @@ def _input_filename(f): _global_var("input_filename"; f);
def _input_filenames: _global_var("input_filenames");
def _input_filenames(f): _global_var("input_filenames"; f);

def _input_strings: _global_var("input_strings");
def _input_strings(f): _global_var("input_strings"; f);

def _input_strings_lines: _global_var("input_strings_lines");
def _input_strings_lines(f): _global_var("input_strings_lines"; f);

def _input_io_errors: _global_var("input_io_errors");
def _input_io_errors(f): _global_var("input_io_errors"; f);

Expand Down

0 comments on commit ac8cfca

Please sign in to comment.