1
1
mirror of https://github.com/wader/fq.git synced 2024-11-22 07:16:49 +03:00

interp: Support force decode as -o force=true

This commit is contained in:
Mattias Wadman 2022-02-05 17:16:10 +01:00
parent 6b8867180c
commit 366f6b185c
4 changed files with 24 additions and 0 deletions

View File

@ -50,6 +50,11 @@ fq 'grep_by(.type=="trak")' file
fq 'grep("^prefix")' file
fq 'grep(123)' file
fq 'grep_by(. >= 100 and . =< 100)' file
# decode file as mp4 and return a result even if there are some errors
fq -d mp4 file.mp4
# decode file as mp4 and also ignore validity assertions
fq -o force=true -d mp4 file.mp4
```
### Display output

View File

@ -37,6 +37,7 @@ def _opt_build_default_fixed:
expr_eval_path: "arg",
expr_file: null,
filenames: null,
force: false,
include_path: null,
join_string: "\n",
null_input: false,
@ -120,6 +121,7 @@ def _opt_cli_arg_options:
expr: (.expr | _opt_tostring),
expr_file: (.expr_file | _opt_tostring),
filenames: (.filenames | _opt_toarray(type == "string")),
force: (.force | _opt_toboolean),
include_path: (.include_path | _opt_tostring),
join_string: (.join_string | _opt_tostring),
line_bytes: (.line_bytes | _opt_tonumber),

View File

@ -53,6 +53,20 @@ $ fq -d raw 'tobytes[0:1] | png | d' /test.mp3
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: (png)
| | | error: png: RawLen(signature): failed at position 0 (read size 0 seek pos 0): outside buffer
0x0|49 |I | unknown0: raw bits
$ fq -o force=true -d png d /test.mp3
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: /test.mp3 (png)
| | | error: png: BitBufRange: failed at position 0 (read size 2315363 seek pos 0): outside buffer
0x000|49 44 33 04 00 00 00 00 |ID3..... | signature: raw bits (invalid)
| | | chunks[0:1]:
| | | [0]{}:
0x000| 00 23 54 53 | .#TS | length: 2315347
0x000| 53 45 00 00| SE..| type: "SE\x00\x00"
0x000| 53 | S | ancillary: true
0x000| 45 | E | private: false
0x000| 00 | . | reserved: false
0x000| 00| .| safe_to_copy: false
0x010|00 0f 00 00 03 4c 61 76 66 35 38 2e 34 35 2e 31|.....Lavf58.45.1| unknown0: raw bits
* |until 0x283.7 (end) (628) | |
$ fq -d raw 'tobytes[0:1] | try probe catch . | type' /test.mp3
"array"
$ fq -d raw 'png({force: true}) | d' /test.mp3

View File

@ -20,6 +20,7 @@ $ fq -n options
"filenames": [
null
],
"force": false,
"include_path": null,
"join_string": "\n",
"line_bytes": 16,
@ -80,6 +81,8 @@ stderr:
error: open testdata/test.jq: no such file or directory
$ fq -o 'filenames=["/test.mp3"]' format
"mp3"
$ fq -o 'force=true' -n options.force
true
$ fq -o include_path=path -n options.include_path
"path"
$ fq -o 'join_string=aaa\n' -n options.join_string