Skip to content

Commit

Permalink
cli: Unbreak part of completion
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Sep 12, 2021
1 parent f8e5944 commit 48517c7
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion format/mp4/testdata/vp9.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ $ fq -d mp4 verbose /vp9.mp4
0x1770| 02 | . | colour_primaries: 2 0x1772-0x1772.7 (1)
0x1770| 02 | . | transfer_characteristics: 2 0x1773-0x1773.7 (1)
0x1770| 02 | . | matrix_coefficients: 2 0x1774-0x1774.7 (1)
0x1770| 00 00 | .. | codec_intialization_data_size: 0 0x1775-0x1776.7 (2)
0x1770| 00 00 | .. | codec_initialization_data_size: 0 0x1775-0x1776.7 (2)
| | | [1]: box {} 0x1777-0x1780.7 (10)
0x1770| 00 00 00 0a | .... | size: 10 0x1777-0x177a.7 (4)
0x1770| 66 69 65 6c | fiel | type: "fiel" (Video field order) 0x177b-0x177e.7 (4)
Expand Down
4 changes: 2 additions & 2 deletions format/vpx/vpx_ccr.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func vpxCCRDecode(d *decode.D, in interface{}) interface{} {
d.FieldU8("colour_primaries")
d.FieldU8("transfer_characteristics")
d.FieldU8("matrix_coefficients")
_ = d.FieldU16("codec_intialization_data_size")
// d.FieldBitBufLen("codec_intialization_data", int64(initDataSize)*8)
_ = d.FieldU16("codec_initialization_data_size")
// d.FieldBitBufLen("codec_initialization_data", int64(initDataSize)*8)

return nil
}
4 changes: 4 additions & 0 deletions pkg/interp/funcs.jq
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def verbose: verbose({});
def v($opts): verbose($opts);
def v: verbose;

def decode($name; $opts): _decode($name; $opts);
def decode($name): _decode($name; {});
def decode: _decode("probe"; {});

# integer division
# inspried by https://github.com/itchyny/gojq/issues/63#issuecomment-765066351
def intdiv($a; $b): ($a - ($a % $b)) / $b;
Expand Down
7 changes: 4 additions & 3 deletions pkg/interp/interp.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,10 +623,11 @@ func (i *Interp) Eval(ctx context.Context, mode RunMode, c interface{}, src stri
return bytes.NewReader(sb.Bytes()), nil
} else if filename == "decode.jq" {
sb := &bytes.Buffer{}
fmt.Fprintf(sb, "def decode($name; $opts): _decode($name; $opts);\n")
fmt.Fprintf(sb, "def decode($name): _decode($name; {});\n")
fmt.Fprintf(sb, "def decode: _decode(\"probe\"; {});\n")
for name := range i.registry.Groups {
// TODO: nicer way to skip all which also would override builtin all/*
if name == "all" {
continue
}
fmt.Fprintf(sb, ""+
"def %[1]s($opts): _decode(%[1]q; $opts);\n"+
"def %[1]s: _decode(%[1]q; {});\n",
Expand Down
2 changes: 1 addition & 1 deletion pkg/interp/interp.jq
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _complete($e; $cursor_pos):
else null
end
);
# only complete if at end of there is a whitespace for now
# only complete if at end or there is a whitespace for now
if ($e[$cursor_pos] | . == "" or . == " ") then
( . as $c
| ( $e[0:$cursor_pos] | _complete_query) as {$type, $query, $prefix}
Expand Down
4 changes: 4 additions & 0 deletions pkg/interp/testdata/completion.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@ _start
_stop
_symbol
_unknown
mp3> .frames\t
frames[]
mp3> .frames[]\t
.
mp3> ^D
2 changes: 2 additions & 0 deletions pkg/interp/testdata/gojq.fqtest
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# TODO: various gojq fq fork regression tests, should probably be move to fork code instead
/test.mp3:
$ fq -n '[true] | all'
true
$ fq -n '{a:1, b: 2} | tostream'
[
[
Expand Down

0 comments on commit 48517c7

Please sign in to comment.