Skip to content

Commit

Permalink
doc: Cleanup and note about repl limit
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Sep 12, 2021
1 parent a49e924 commit 0a97f86
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
4 changes: 2 additions & 2 deletions dev/format_summary.jq
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def recurse_depth(f; cond):

[ ( recurse_depth(
.[]?;
._format
format
)
| . + {
norm_path: (.value._path | map(if type == "number" then "index" end)),
Expand All @@ -27,7 +27,7 @@ def recurse_depth(f; cond):
| map(.[0] + {count: length})
| .[]
| [ if .depth > 0 then " "*.depth else empty end
, (.value._format + if .count > 1 then "*\(.count) " else " " end)
, ((.value | format) + if .count > 1 then "*\(.count) " else " " end)
, (.value._path | path_to_expr)
]
| join("")
Expand Down
2 changes: 1 addition & 1 deletion dev/x264sei.jq
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# x264 - core 161 r3020 d198931 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00

( ..
| select(._format == "avc_sei" and .uuid._symbol == "x264")
| select(format == "avc_sei" and .uuid._symbol == "x264")
| .data
| tostring[0:-1]
| . as $full
Expand Down
23 changes: 14 additions & 9 deletions doc/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,17 @@ TODO: format graph?
TODO


### Useful tricks
### Known issues and useful tricks

#### Run interactive mode with no input
```sh
fq -i
null>
```

#### `.. | select(...)` fails with `expected an ... but got: ...`

Try add `select(...)?` the select expression assumes it will get and object etc.
Try add `select(...)?` to catch type errors in the select expression.

#### Manual decode

Expand All @@ -229,9 +235,9 @@ $ fq file.mp3 .unknown0._bytes[10:] mp3_frame
This won't work as expected `.a | f(.b)` as `.` is `.a` when evaluating the arguments.
Instead do `. as $c | .a | f($c.b)`.

#### Appending to array is slow
#### Building array is slow

Try to use `map` or `foreach` instead.
Try to use `map` or `foreach` to avoid rebuilding the whole array for each append.

#### Use `print` and `println` to produce more friendly compact output

Expand All @@ -252,8 +258,7 @@ Try to use `map` or `foreach` instead.
1: b
```

#### Run interactive mode with no input
```sh
fq -i
null>
```
### `repl` argument using function or variable causes `variable not defined`

`true as $verbose | repl({verbose: $verbose})` will currently fail as `repl` is
implemented by rewriting the query to `map(true as $verbose | .) | repl({verbose: $verbose})`.
4 changes: 1 addition & 3 deletions pkg/interp/funcs.jq
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


def display($opts): _display($opts);
def display: _display({});
def d($opts): _display($opts);
Expand All @@ -17,7 +15,7 @@ def v: verbose;
# inspried by https://github.com/itchyny/gojq/issues/63#issuecomment-765066351
def intdiv($a; $b): ($a - ($a % $b)) / $b;

# valid jq identifer, start with alpha or underscore then zero or more alpha, num or underscore
# valid jq identifier, start with alpha or underscore then zero or more alpha, num or underscore
def _is_ident: type == "string" and test("^[a-zA-Z_][a-zA-Z_0-9]*$");
# escape " and \
def _escape_ident: gsub("(?<g>[\\\\\"])"; "\\\(.g)");
Expand Down

0 comments on commit 0a97f86

Please sign in to comment.