1
1
mirror of https://github.com/wader/fq.git synced 2024-11-23 09:56:07 +03:00

cli: Unbreak part of completion

This commit is contained in:
Mattias Wadman 2021-09-06 15:37:55 +02:00
parent f8e5944f91
commit 48517c7c60
7 changed files with 18 additions and 7 deletions

View File

@ -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)

View File

@ -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
}

View File

@ -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;

View File

@ -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",

View File

@ -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}

View File

@ -44,4 +44,8 @@ _start
_stop
_symbol
_unknown
mp3> .frames\t
frames[]
mp3> .frames[]\t
.
mp3> ^D

View File

@ -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'
[
[