From 48517c7c6015e524cf03ffea104eb8d8e55d8e47 Mon Sep 17 00:00:00 2001 From: Mattias Wadman Date: Mon, 6 Sep 2021 15:37:55 +0200 Subject: [PATCH] cli: Unbreak part of completion --- format/mp4/testdata/vp9.fqtest | 2 +- format/vpx/vpx_ccr.go | 4 ++-- pkg/interp/funcs.jq | 4 ++++ pkg/interp/interp.go | 7 ++++--- pkg/interp/interp.jq | 2 +- pkg/interp/testdata/completion.fqtest | 4 ++++ pkg/interp/testdata/gojq.fqtest | 2 ++ 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/format/mp4/testdata/vp9.fqtest b/format/mp4/testdata/vp9.fqtest index a06e46de..66cb01f6 100644 --- a/format/mp4/testdata/vp9.fqtest +++ b/format/mp4/testdata/vp9.fqtest @@ -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) diff --git a/format/vpx/vpx_ccr.go b/format/vpx/vpx_ccr.go index 4210caf1..587616db 100644 --- a/format/vpx/vpx_ccr.go +++ b/format/vpx/vpx_ccr.go @@ -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 } diff --git a/pkg/interp/funcs.jq b/pkg/interp/funcs.jq index a2959874..2cc8a6b0 100644 --- a/pkg/interp/funcs.jq +++ b/pkg/interp/funcs.jq @@ -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; diff --git a/pkg/interp/interp.go b/pkg/interp/interp.go index 2f80dfa2..6e7d011e 100644 --- a/pkg/interp/interp.go +++ b/pkg/interp/interp.go @@ -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", diff --git a/pkg/interp/interp.jq b/pkg/interp/interp.jq index 117d2a49..50d62d5a 100644 --- a/pkg/interp/interp.jq +++ b/pkg/interp/interp.jq @@ -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} diff --git a/pkg/interp/testdata/completion.fqtest b/pkg/interp/testdata/completion.fqtest index 71e43c72..7f0ec475 100644 --- a/pkg/interp/testdata/completion.fqtest +++ b/pkg/interp/testdata/completion.fqtest @@ -44,4 +44,8 @@ _start _stop _symbol _unknown +mp3> .frames\t +frames[] +mp3> .frames[]\t +. mp3> ^D diff --git a/pkg/interp/testdata/gojq.fqtest b/pkg/interp/testdata/gojq.fqtest index bc4b56d7..5cc732f9 100644 --- a/pkg/interp/testdata/gojq.fqtest +++ b/pkg/interp/testdata/gojq.fqtest @@ -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' [ [