From b84989597052232777ab517f2490355579288f50 Mon Sep 17 00:00:00 2001 From: Mattias Wadman Date: Mon, 30 Aug 2021 12:51:42 +0200 Subject: [PATCH] fq: Add truncate array support to dump/display --- doc/usage.md | 6 +- pkg/decode/value.go | 7 + pkg/interp/dump.go | 21 +- pkg/interp/funcs.go | 3 +- pkg/interp/interp.go | 4 + pkg/interp/interp.jq | 2 + pkg/interp/testdata/args.fqtest | 1 + pkg/interp/testdata/display.fqtest | 368 ++++++++++++++++++++++++++++- pkg/interp/testdata/options.fqtest | 5 + pkg/interp/testdata/value.fqtest | 51 +--- 10 files changed, 408 insertions(+), 60 deletions(-) diff --git a/doc/usage.md b/doc/usage.md index a358fb6b82..59c840093a 100644 --- a/doc/usage.md +++ b/doc/usage.md @@ -18,6 +18,7 @@ Usage: fq [OPTIONS] [--] [EXPR] [FILE...] --null-output,-0 Null byte between outputs --option,-o KEY=VALUE Set option, eg: color=true addrbase=16 + arraytruncate=50 bitsformat=snippet bytecolors=0-0xff=brightwhite,0=brightblack,32-126:9-13=white color=false @@ -100,8 +101,9 @@ notable is support for arbitrary-precision integers. - `open` open file for reading - `probe` or `decode` try to automatically detect format and decode - `mp3`, `matroska`, ..., ``, `decode([name])` try decode as format -- `d`/`display` display value -- `v`/`verbose` display value verbosely +- `d`/`display` display value and truncate long arrays +- `f`/`full` display value and don't truncate arrays +- `v`/`verbose` display value verbosely and don't truncate array - `p`/`preview` show preview of field tree - `hd`/`hexdump` hexdump value - `repl` nested REPL diff --git a/pkg/decode/value.go b/pkg/decode/value.go index d57893275c..3f3295e13e 100644 --- a/pkg/decode/value.go +++ b/pkg/decode/value.go @@ -56,6 +56,7 @@ type Value struct { type WalkFn func(v *Value, rootV *Value, depth int, rootDepth int) error var ErrWalkSkipChildren = errors.New("skip children") +var ErrWalkBreak = errors.New("break") var ErrWalkStop = errors.New("stop") func (v *Value) walk(preOrder bool, fn WalkFn) error { @@ -85,12 +86,18 @@ func (v *Value) walk(preOrder bool, fn WalkFn) error { case Struct: for _, wv := range v { if err := walkFn(wv, rootV, depth+1, rootDepth+rootDepthDelta); err != nil { + if errors.Is(err, ErrWalkBreak) { + break + } return err } } case Array: for _, wv := range v { if err := walkFn(wv, rootV, depth+1, rootDepth+rootDepthDelta); err != nil { + if errors.Is(err, ErrWalkBreak) { + break + } return err } } diff --git a/pkg/interp/dump.go b/pkg/interp/dump.go index bf9c9d9b3a..8d1f12c193 100644 --- a/pkg/interp/dump.go +++ b/pkg/interp/dump.go @@ -52,8 +52,12 @@ func dumpEx(v *decode.Value, cw *columnwriter.Writer, depth int, rootV *decode.V } isInArray := false + inArrayLen := 0 if v.Parent != nil { - _, isInArray = v.Parent.V.(decode.Array) + if da, ok := v.Parent.V.(decode.Array); ok { + isInArray = true + inArrayLen = len(da) + } } nameV := v @@ -86,6 +90,19 @@ func dumpEx(v *decode.Value, cw *columnwriter.Writer, depth int, rootV *decode.V } } + if opts.ArrayTruncate != 0 && depth != 0 && isInArray && v.Index >= opts.ArrayTruncate { + columns() + cfmt(colField, "%s%s%s:%s%s: ...", + indent, + deco.Index.F("["), + deco.Number.F(strconv.Itoa(v.Index)), + deco.Number.F(strconv.Itoa(inArrayLen-1)), + deco.Index.F("]"), + ) + cw.Flush() + return decode.ErrWalkBreak + } + cfmt(colField, "%s%s", indent, name) if isInArray { cfmt(colField, "%s%s%s", deco.Index.F("["), deco.Number.F(strconv.Itoa(v.Index)), deco.Index.F("]")) @@ -95,6 +112,8 @@ func dumpEx(v *decode.Value, cw *columnwriter.Writer, depth int, rootV *decode.V cfmt(colField, " %s", v.Name) } + // TODO: cleanup map[string]interface{} []interface{} or json format + // dump should use some internal interface instead? switch v.V.(type) { case decode.Struct, map[string]interface{}: cfmt(colField, " %s", deco.Object.F("{}")) diff --git a/pkg/interp/funcs.go b/pkg/interp/funcs.go index e6b530be09..4cd1752121 100644 --- a/pkg/interp/funcs.go +++ b/pkg/interp/funcs.go @@ -54,7 +54,8 @@ func (i *Interp) makeFunctions(registry *registry.Registry) []Function { {[]string{"format"}, 0, 0, i.format, nil}, {[]string{"display", "d"}, 0, 1, nil, i.makeDisplayFn(nil)}, - {[]string{"verbose", "v"}, 0, 1, nil, i.makeDisplayFn(map[string]interface{}{"verbose": true})}, + {[]string{"full", "f"}, 0, 1, nil, i.makeDisplayFn(map[string]interface{}{"arraytruncate": 0})}, + {[]string{"verbose", "v"}, 0, 1, nil, i.makeDisplayFn(map[string]interface{}{"arraytruncate": 0, "verbose": true})}, {[]string{"preview", "p"}, 0, 1, nil, i.preview}, {[]string{"hexdump", "hd", "h"}, 0, 1, nil, i.hexdump}, diff --git a/pkg/interp/interp.go b/pkg/interp/interp.go index 9b0203e9ab..19b690a052 100644 --- a/pkg/interp/interp.go +++ b/pkg/interp/interp.go @@ -787,6 +787,7 @@ func (i *Interp) EvalFuncValues(ctx context.Context, mode RunMode, c interface{} type Options struct { Depth int + ArrayTruncate int Verbose bool DecodeProgress bool Color bool @@ -813,6 +814,9 @@ func mapSetOptions(d *Options, m map[string]interface{}) { if v, ok := m["depth"]; ok { d.Depth = num.MaxInt(0, toIntZ(v)) } + if v, ok := m["arraytruncate"]; ok { + d.ArrayTruncate = num.MaxInt(0, toIntZ(v)) + } if v, ok := m["verbose"]; ok { d.Verbose = toBoolZ(v) } diff --git a/pkg/interp/interp.jq b/pkg/interp/interp.jq index 3cb39e2977..eb5e25304a 100644 --- a/pkg/interp/interp.jq +++ b/pkg/interp/interp.jq @@ -48,6 +48,7 @@ def _obj_to_csv_kv: def _build_default_options: { addrbase: 16, + arraytruncate: 50, bitsformat: "snippet", bytecolors: "0-0xff=brightwhite,0=brightblack,32-126:9-13=white", color: (tty.is_terminal and env.CLICOLOR != null), @@ -105,6 +106,7 @@ def _tostring: def _to_options: ( { addrbase: (.addrbase | _tonumber), + arraytruncate: (.arraytruncate | _tonumber), bitsformat: (.bitsformat | _tostring), bytecolors: (.bytecolors | _tostring), color: (.color | _toboolean), diff --git a/pkg/interp/testdata/args.fqtest b/pkg/interp/testdata/args.fqtest index a56704fb92..193762404d 100644 --- a/pkg/interp/testdata/args.fqtest +++ b/pkg/interp/testdata/args.fqtest @@ -20,6 +20,7 @@ Usage: fq [OPTIONS] [--] [EXPR] [FILE...] --null-output,-0 Null byte between outputs --option,-o KEY=VALUE Set option, eg: color=true addrbase=16 + arraytruncate=50 bitsformat=snippet bytecolors=0-0xff=brightwhite,0=brightblack,32-126:9-13=white color=false diff --git a/pkg/interp/testdata/display.fqtest b/pkg/interp/testdata/display.fqtest index f5afb09ec6..ffc9053481 100644 --- a/pkg/interp/testdata/display.fqtest +++ b/pkg/interp/testdata/display.fqtest @@ -1,6 +1,7 @@ # ffmpeg -f lavfi -i sine -t 10ms test.mp3 /test.mp3: -$ fq -d mp3 'display({depth: 1})' /test.mp3 +$ fq -i -d mp3 . /test.mp3 +mp3> display({depth: 1}) |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |.: {} /test.mp3 (mp3) 0x000|49 44 33 04 00 00 00 00 00 23 54 53 53 45 00 00|ID3......#TSSE..| headers: [1] * |until 0x2c.7 (45) | | @@ -8,7 +9,7 @@ $ fq -d mp3 'display({depth: 1})' /test.mp3 0x030|c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................| * |until 0x283.7 (end) (599) | | | | | footers: [0] -$ fq -d mp3 'display({depth: 2})' /test.mp3 +mp3> display({depth: 2}) |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |.: {} /test.mp3 (mp3) | | | headers: [1] 0x000|49 44 33 04 00 00 00 00 00 23 54 53 53 45 00 00|ID3......#TSSE..| [0]: {} (id3v2) @@ -24,7 +25,7 @@ $ fq -d mp3 'display({depth: 2})' /test.mp3 0x1c0|00 00 00 34 80 00 00 04 11 4b 36 4a 08 83 58 c9|...4.....K6J..X.| * |until 0x283.7 (end) (209) | | | | | footers: [0] -$ fq -d mp3 'display({depth: 1, displaybytes: 8})' /test.mp3 +mp3> display({depth: 1, displaybytes: 8}) |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |.: {} /test.mp3 (mp3) 0x000|49 44 33 04 00 00 00 00 00 23 54 53 53 45 00 00|ID3......#TSSE..| headers: [1] * |until 0x2c.7 (45) | | @@ -32,7 +33,7 @@ $ fq -d mp3 'display({depth: 1, displaybytes: 8})' /test.mp3 0x030|c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................| * |until 0x283.7 (end) (599) | | | | | footers: [0] -$ fq -d mp3 'display({depth: 1, linebytes: 8})' /test.mp3 +mp3> display({depth: 1, linebytes: 8}) |00 01 02 03 04 05 06 07| |.: {} /test.mp3 (mp3) 0x000|49 44 33 04 00 00 00 00|ID3.....| headers: [1] 0x008|00 23 54 53 53 45 00 00|.#TSSE..| @@ -42,7 +43,7 @@ $ fq -d mp3 'display({depth: 1, linebytes: 8})' /test.mp3 0x038|00 00 00 00 00 00 00 00|........| * |until 0x283.7 (end) (599)| | | | | footers: [0] -$ fq -d mp3 '.frames[0] | verbose({depth: 1, addrbase: 10})' /test.mp3 +mp3> .frames[0] | verbose({depth: 1, addrbase: 10}) |00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15| |.frames[0]: frame {} (mp3_frame) 45-226.7 (182) 032| ff fb 40| ..@| header: {} 45-48.7 (4) 048|c0 |. | @@ -54,7 +55,7 @@ $ fq -d mp3 '.frames[0] | verbose({depth: 1, addrbase: 10})' /test.mp3 208| 00 00| ..| padding: 0000000000 222-226.7 (5) 224|00 00 00 |... | | | | crc_calculated: 827a 227-NA (0) -$ fq -d mp3 '.frames[0] | verbose({depth: 1, sizebase: 16})' /test.mp3 +mp3> .frames[0] | verbose({depth: 1, sizebase: 16}) |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |.frames[0]: frame {} (mp3_frame) 0x2d-0xe2.7 (0xb6) 0x20| ff fb 40| ..@| header: {} 0x2d-0x30.7 (0x4) 0x30|c0 |. | @@ -66,3 +67,358 @@ $ fq -d mp3 '.frames[0] | verbose({depth: 1, sizebase: 16})' /test.mp3 0xd0| 00 00| ..| padding: 0000000000 0xde-0xe2.7 (0x5) 0xe0|00 00 00 |... | | | | crc_calculated: 827a 0xe3-NA (0x0) +mp3> .frames[0].xing | d, f, v + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |.frames[0].xing: {} (xing) +0x40| 49 6e 66 6f | Info | header: "Info" + | | | present_flags: {} +0x40| 00 00 00 0f | .... | unused: 0 +0x40| 0f | . | quality: true +0x40| 0f | . | toc: true +0x40| 0f | . | bytes: true +0x40| 0f | . | frames: true +0x40| 00 00 00 02 | .... | frames: 2 +0x40| 00 00| ..| bytes: 599 +0x50|02 57 |.W | + | | | toc: [100] +0x50| 00 | . | [0]: 0 +0x50| a6 | . | [1]: 166 +0x50| a6 | . | [2]: 166 +0x50| a6 | . | [3]: 166 +0x50| a6 | . | [4]: 166 +0x50| a6 | . | [5]: 166 +0x50| a6 | . | [6]: 166 +0x50| a6 | . | [7]: 166 +0x50| a6 | . | [8]: 166 +0x50| a6 | . | [9]: 166 +0x50| a6 | . | [10]: 166 +0x50| a6 | . | [11]: 166 +0x50| a6 | . | [12]: 166 +0x50| a6| .| [13]: 166 +0x60|a6 |. | [14]: 166 +0x60| a6 | . | [15]: 166 +0x60| a6 | . | [16]: 166 +0x60| a6 | . | [17]: 166 +0x60| a6 | . | [18]: 166 +0x60| a6 | . | [19]: 166 +0x60| a6 | . | [20]: 166 +0x60| a6 | . | [21]: 166 +0x60| a6 | . | [22]: 166 +0x60| a6 | . | [23]: 166 +0x60| a6 | . | [24]: 166 +0x60| a6 | . | [25]: 166 +0x60| a6 | . | [26]: 166 +0x60| a6 | . | [27]: 166 +0x60| a6 | . | [28]: 166 +0x60| a6| .| [29]: 166 +0x70|a6 |. | [30]: 166 +0x70| a6 | . | [31]: 166 +0x70| a6 | . | [32]: 166 +0x70| a6 | . | [33]: 166 +0x70| a6 | . | [34]: 166 +0x70| a6 | . | [35]: 166 +0x70| a6 | . | [36]: 166 +0x70| a6 | . | [37]: 166 +0x70| a6 | . | [38]: 166 +0x70| a6 | . | [39]: 166 +0x70| a6 | . | [40]: 166 +0x70| a6 | . | [41]: 166 +0x70| a6 | . | [42]: 166 +0x70| a6 | . | [43]: 166 +0x70| a6 | . | [44]: 166 +0x70| a6| .| [45]: 166 +0x80|a6 |. | [46]: 166 +0x80| a6 | . | [47]: 166 +0x80| a6 | . | [48]: 166 +0x80| a6 | . | [49]: 166 + | | | [50:99]: ... +0xb0| 00 00 00 00 | .... | quality: 0 + | | | lame_extension: {} +0xb0| 4c 61 76 63 35 38| Lavc58| encoder: "Lavc58.91" +0xc0|2e 39 31 |.91 | +0xc0| 00 | . | tag_revision: 0 +0xc0| 00 | . | vbr_method: 0 +0xc0| 00 | . | lowpass_filter: 0 +0xc0| 00 00 00 00 | .... | replay_gain_peak: 0 +0xc0| 00 00 | .. | radio_replay_gain: 0 +0xc0| 00 00 | .. | audiophile_replay_gain: 0 +0xc0| 00 | . | lame_flags: 0 +0xc0| 00 | . | lame_ath_type: 0 +0xc0| 00 | . | abr_vbr: 0 +0xc0| 24| $| encoder_delay: 576 +0xd0|05 |. | +0xd0|05 07 |.. | encoder_padding: 1287 +0xd0| 00 | . | misc: 0 +0xd0| 00 | . | mp3_gain: 0 +0xd0| 00 00 | .. | preset: 0 +0xd0| 00 00 02 57 | ...W | length: 599 +0xd0| 62 f0 | b. | music_crc: 25328 +0xd0| 5a 35 | Z5 | tag_crc: 23093 + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |.frames[0].xing: {} (xing) +0x40| 49 6e 66 6f | Info | header: "Info" + | | | present_flags: {} +0x40| 00 00 00 0f | .... | unused: 0 +0x40| 0f | . | quality: true +0x40| 0f | . | toc: true +0x40| 0f | . | bytes: true +0x40| 0f | . | frames: true +0x40| 00 00 00 02 | .... | frames: 2 +0x40| 00 00| ..| bytes: 599 +0x50|02 57 |.W | + | | | toc: [100] +0x50| 00 | . | [0]: 0 +0x50| a6 | . | [1]: 166 +0x50| a6 | . | [2]: 166 +0x50| a6 | . | [3]: 166 +0x50| a6 | . | [4]: 166 +0x50| a6 | . | [5]: 166 +0x50| a6 | . | [6]: 166 +0x50| a6 | . | [7]: 166 +0x50| a6 | . | [8]: 166 +0x50| a6 | . | [9]: 166 +0x50| a6 | . | [10]: 166 +0x50| a6 | . | [11]: 166 +0x50| a6 | . | [12]: 166 +0x50| a6| .| [13]: 166 +0x60|a6 |. | [14]: 166 +0x60| a6 | . | [15]: 166 +0x60| a6 | . | [16]: 166 +0x60| a6 | . | [17]: 166 +0x60| a6 | . | [18]: 166 +0x60| a6 | . | [19]: 166 +0x60| a6 | . | [20]: 166 +0x60| a6 | . | [21]: 166 +0x60| a6 | . | [22]: 166 +0x60| a6 | . | [23]: 166 +0x60| a6 | . | [24]: 166 +0x60| a6 | . | [25]: 166 +0x60| a6 | . | [26]: 166 +0x60| a6 | . | [27]: 166 +0x60| a6 | . | [28]: 166 +0x60| a6| .| [29]: 166 +0x70|a6 |. | [30]: 166 +0x70| a6 | . | [31]: 166 +0x70| a6 | . | [32]: 166 +0x70| a6 | . | [33]: 166 +0x70| a6 | . | [34]: 166 +0x70| a6 | . | [35]: 166 +0x70| a6 | . | [36]: 166 +0x70| a6 | . | [37]: 166 +0x70| a6 | . | [38]: 166 +0x70| a6 | . | [39]: 166 +0x70| a6 | . | [40]: 166 +0x70| a6 | . | [41]: 166 +0x70| a6 | . | [42]: 166 +0x70| a6 | . | [43]: 166 +0x70| a6 | . | [44]: 166 +0x70| a6| .| [45]: 166 +0x80|a6 |. | [46]: 166 +0x80| a6 | . | [47]: 166 +0x80| a6 | . | [48]: 166 +0x80| a6 | . | [49]: 166 +0x80| ff | . | [50]: 255 +0x80| ff | . | [51]: 255 +0x80| ff | . | [52]: 255 +0x80| ff | . | [53]: 255 +0x80| ff | . | [54]: 255 +0x80| ff | . | [55]: 255 +0x80| ff | . | [56]: 255 +0x80| ff | . | [57]: 255 +0x80| ff | . | [58]: 255 +0x80| ff | . | [59]: 255 +0x80| ff | . | [60]: 255 +0x80| ff| .| [61]: 255 +0x90|ff |. | [62]: 255 +0x90| ff | . | [63]: 255 +0x90| ff | . | [64]: 255 +0x90| ff | . | [65]: 255 +0x90| ff | . | [66]: 255 +0x90| ff | . | [67]: 255 +0x90| ff | . | [68]: 255 +0x90| ff | . | [69]: 255 +0x90| ff | . | [70]: 255 +0x90| ff | . | [71]: 255 +0x90| ff | . | [72]: 255 +0x90| ff | . | [73]: 255 +0x90| ff | . | [74]: 255 +0x90| ff | . | [75]: 255 +0x90| ff | . | [76]: 255 +0x90| ff| .| [77]: 255 +0xa0|ff |. | [78]: 255 +0xa0| ff | . | [79]: 255 +0xa0| ff | . | [80]: 255 +0xa0| ff | . | [81]: 255 +0xa0| ff | . | [82]: 255 +0xa0| ff | . | [83]: 255 +0xa0| ff | . | [84]: 255 +0xa0| ff | . | [85]: 255 +0xa0| ff | . | [86]: 255 +0xa0| ff | . | [87]: 255 +0xa0| ff | . | [88]: 255 +0xa0| ff | . | [89]: 255 +0xa0| ff | . | [90]: 255 +0xa0| ff | . | [91]: 255 +0xa0| ff | . | [92]: 255 +0xa0| ff| .| [93]: 255 +0xb0|ff |. | [94]: 255 +0xb0| ff | . | [95]: 255 +0xb0| ff | . | [96]: 255 +0xb0| ff | . | [97]: 255 +0xb0| ff | . | [98]: 255 +0xb0| ff | . | [99]: 255 +0xb0| 00 00 00 00 | .... | quality: 0 + | | | lame_extension: {} +0xb0| 4c 61 76 63 35 38| Lavc58| encoder: "Lavc58.91" +0xc0|2e 39 31 |.91 | +0xc0| 00 | . | tag_revision: 0 +0xc0| 00 | . | vbr_method: 0 +0xc0| 00 | . | lowpass_filter: 0 +0xc0| 00 00 00 00 | .... | replay_gain_peak: 0 +0xc0| 00 00 | .. | radio_replay_gain: 0 +0xc0| 00 00 | .. | audiophile_replay_gain: 0 +0xc0| 00 | . | lame_flags: 0 +0xc0| 00 | . | lame_ath_type: 0 +0xc0| 00 | . | abr_vbr: 0 +0xc0| 24| $| encoder_delay: 576 +0xd0|05 |. | +0xd0|05 07 |.. | encoder_padding: 1287 +0xd0| 00 | . | misc: 0 +0xd0| 00 | . | mp3_gain: 0 +0xd0| 00 00 | .. | preset: 0 +0xd0| 00 00 02 57 | ...W | length: 599 +0xd0| 62 f0 | b. | music_crc: 25328 +0xd0| 5a 35 | Z5 | tag_crc: 23093 + |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |.frames[0].xing: {} (xing) 0x42-0xdd.7 (156) +0x40| 49 6e 66 6f | Info | header: "Info" 0x42-0x45.7 (4) + | | | present_flags: {} 0x46-0x49.7 (4) +0x40| 00 00 00 0f | .... | unused: 0 0x46-0x49.3 (3.4) +0x40| 0f | . | quality: true 0x49.4-0x49.4 (0.1) +0x40| 0f | . | toc: true 0x49.5-0x49.5 (0.1) +0x40| 0f | . | bytes: true 0x49.6-0x49.6 (0.1) +0x40| 0f | . | frames: true 0x49.7-0x49.7 (0.1) +0x40| 00 00 00 02 | .... | frames: 2 0x4a-0x4d.7 (4) +0x40| 00 00| ..| bytes: 599 0x4e-0x51.7 (4) +0x50|02 57 |.W | + | | | toc: [100] 0x52-0xb5.7 (100) +0x50| 00 | . | [0]: entry 0 0x52-0x52.7 (1) +0x50| a6 | . | [1]: entry 166 0x53-0x53.7 (1) +0x50| a6 | . | [2]: entry 166 0x54-0x54.7 (1) +0x50| a6 | . | [3]: entry 166 0x55-0x55.7 (1) +0x50| a6 | . | [4]: entry 166 0x56-0x56.7 (1) +0x50| a6 | . | [5]: entry 166 0x57-0x57.7 (1) +0x50| a6 | . | [6]: entry 166 0x58-0x58.7 (1) +0x50| a6 | . | [7]: entry 166 0x59-0x59.7 (1) +0x50| a6 | . | [8]: entry 166 0x5a-0x5a.7 (1) +0x50| a6 | . | [9]: entry 166 0x5b-0x5b.7 (1) +0x50| a6 | . | [10]: entry 166 0x5c-0x5c.7 (1) +0x50| a6 | . | [11]: entry 166 0x5d-0x5d.7 (1) +0x50| a6 | . | [12]: entry 166 0x5e-0x5e.7 (1) +0x50| a6| .| [13]: entry 166 0x5f-0x5f.7 (1) +0x60|a6 |. | [14]: entry 166 0x60-0x60.7 (1) +0x60| a6 | . | [15]: entry 166 0x61-0x61.7 (1) +0x60| a6 | . | [16]: entry 166 0x62-0x62.7 (1) +0x60| a6 | . | [17]: entry 166 0x63-0x63.7 (1) +0x60| a6 | . | [18]: entry 166 0x64-0x64.7 (1) +0x60| a6 | . | [19]: entry 166 0x65-0x65.7 (1) +0x60| a6 | . | [20]: entry 166 0x66-0x66.7 (1) +0x60| a6 | . | [21]: entry 166 0x67-0x67.7 (1) +0x60| a6 | . | [22]: entry 166 0x68-0x68.7 (1) +0x60| a6 | . | [23]: entry 166 0x69-0x69.7 (1) +0x60| a6 | . | [24]: entry 166 0x6a-0x6a.7 (1) +0x60| a6 | . | [25]: entry 166 0x6b-0x6b.7 (1) +0x60| a6 | . | [26]: entry 166 0x6c-0x6c.7 (1) +0x60| a6 | . | [27]: entry 166 0x6d-0x6d.7 (1) +0x60| a6 | . | [28]: entry 166 0x6e-0x6e.7 (1) +0x60| a6| .| [29]: entry 166 0x6f-0x6f.7 (1) +0x70|a6 |. | [30]: entry 166 0x70-0x70.7 (1) +0x70| a6 | . | [31]: entry 166 0x71-0x71.7 (1) +0x70| a6 | . | [32]: entry 166 0x72-0x72.7 (1) +0x70| a6 | . | [33]: entry 166 0x73-0x73.7 (1) +0x70| a6 | . | [34]: entry 166 0x74-0x74.7 (1) +0x70| a6 | . | [35]: entry 166 0x75-0x75.7 (1) +0x70| a6 | . | [36]: entry 166 0x76-0x76.7 (1) +0x70| a6 | . | [37]: entry 166 0x77-0x77.7 (1) +0x70| a6 | . | [38]: entry 166 0x78-0x78.7 (1) +0x70| a6 | . | [39]: entry 166 0x79-0x79.7 (1) +0x70| a6 | . | [40]: entry 166 0x7a-0x7a.7 (1) +0x70| a6 | . | [41]: entry 166 0x7b-0x7b.7 (1) +0x70| a6 | . | [42]: entry 166 0x7c-0x7c.7 (1) +0x70| a6 | . | [43]: entry 166 0x7d-0x7d.7 (1) +0x70| a6 | . | [44]: entry 166 0x7e-0x7e.7 (1) +0x70| a6| .| [45]: entry 166 0x7f-0x7f.7 (1) +0x80|a6 |. | [46]: entry 166 0x80-0x80.7 (1) +0x80| a6 | . | [47]: entry 166 0x81-0x81.7 (1) +0x80| a6 | . | [48]: entry 166 0x82-0x82.7 (1) +0x80| a6 | . | [49]: entry 166 0x83-0x83.7 (1) +0x80| ff | . | [50]: entry 255 0x84-0x84.7 (1) +0x80| ff | . | [51]: entry 255 0x85-0x85.7 (1) +0x80| ff | . | [52]: entry 255 0x86-0x86.7 (1) +0x80| ff | . | [53]: entry 255 0x87-0x87.7 (1) +0x80| ff | . | [54]: entry 255 0x88-0x88.7 (1) +0x80| ff | . | [55]: entry 255 0x89-0x89.7 (1) +0x80| ff | . | [56]: entry 255 0x8a-0x8a.7 (1) +0x80| ff | . | [57]: entry 255 0x8b-0x8b.7 (1) +0x80| ff | . | [58]: entry 255 0x8c-0x8c.7 (1) +0x80| ff | . | [59]: entry 255 0x8d-0x8d.7 (1) +0x80| ff | . | [60]: entry 255 0x8e-0x8e.7 (1) +0x80| ff| .| [61]: entry 255 0x8f-0x8f.7 (1) +0x90|ff |. | [62]: entry 255 0x90-0x90.7 (1) +0x90| ff | . | [63]: entry 255 0x91-0x91.7 (1) +0x90| ff | . | [64]: entry 255 0x92-0x92.7 (1) +0x90| ff | . | [65]: entry 255 0x93-0x93.7 (1) +0x90| ff | . | [66]: entry 255 0x94-0x94.7 (1) +0x90| ff | . | [67]: entry 255 0x95-0x95.7 (1) +0x90| ff | . | [68]: entry 255 0x96-0x96.7 (1) +0x90| ff | . | [69]: entry 255 0x97-0x97.7 (1) +0x90| ff | . | [70]: entry 255 0x98-0x98.7 (1) +0x90| ff | . | [71]: entry 255 0x99-0x99.7 (1) +0x90| ff | . | [72]: entry 255 0x9a-0x9a.7 (1) +0x90| ff | . | [73]: entry 255 0x9b-0x9b.7 (1) +0x90| ff | . | [74]: entry 255 0x9c-0x9c.7 (1) +0x90| ff | . | [75]: entry 255 0x9d-0x9d.7 (1) +0x90| ff | . | [76]: entry 255 0x9e-0x9e.7 (1) +0x90| ff| .| [77]: entry 255 0x9f-0x9f.7 (1) +0xa0|ff |. | [78]: entry 255 0xa0-0xa0.7 (1) +0xa0| ff | . | [79]: entry 255 0xa1-0xa1.7 (1) +0xa0| ff | . | [80]: entry 255 0xa2-0xa2.7 (1) +0xa0| ff | . | [81]: entry 255 0xa3-0xa3.7 (1) +0xa0| ff | . | [82]: entry 255 0xa4-0xa4.7 (1) +0xa0| ff | . | [83]: entry 255 0xa5-0xa5.7 (1) +0xa0| ff | . | [84]: entry 255 0xa6-0xa6.7 (1) +0xa0| ff | . | [85]: entry 255 0xa7-0xa7.7 (1) +0xa0| ff | . | [86]: entry 255 0xa8-0xa8.7 (1) +0xa0| ff | . | [87]: entry 255 0xa9-0xa9.7 (1) +0xa0| ff | . | [88]: entry 255 0xaa-0xaa.7 (1) +0xa0| ff | . | [89]: entry 255 0xab-0xab.7 (1) +0xa0| ff | . | [90]: entry 255 0xac-0xac.7 (1) +0xa0| ff | . | [91]: entry 255 0xad-0xad.7 (1) +0xa0| ff | . | [92]: entry 255 0xae-0xae.7 (1) +0xa0| ff| .| [93]: entry 255 0xaf-0xaf.7 (1) +0xb0|ff |. | [94]: entry 255 0xb0-0xb0.7 (1) +0xb0| ff | . | [95]: entry 255 0xb1-0xb1.7 (1) +0xb0| ff | . | [96]: entry 255 0xb2-0xb2.7 (1) +0xb0| ff | . | [97]: entry 255 0xb3-0xb3.7 (1) +0xb0| ff | . | [98]: entry 255 0xb4-0xb4.7 (1) +0xb0| ff | . | [99]: entry 255 0xb5-0xb5.7 (1) +0xb0| 00 00 00 00 | .... | quality: 0 0xb6-0xb9.7 (4) + | | | lame_extension: {} 0xba-0xdd.7 (36) +0xb0| 4c 61 76 63 35 38| Lavc58| encoder: "Lavc58.91" 0xba-0xc2.7 (9) +0xc0|2e 39 31 |.91 | +0xc0| 00 | . | tag_revision: 0 0xc3-0xc3.3 (0.4) +0xc0| 00 | . | vbr_method: 0 0xc3.4-0xc3.7 (0.4) +0xc0| 00 | . | lowpass_filter: 0 0xc4-0xc4.7 (1) +0xc0| 00 00 00 00 | .... | replay_gain_peak: 0 0xc5-0xc8.7 (4) +0xc0| 00 00 | .. | radio_replay_gain: 0 0xc9-0xca.7 (2) +0xc0| 00 00 | .. | audiophile_replay_gain: 0 0xcb-0xcc.7 (2) +0xc0| 00 | . | lame_flags: 0 0xcd-0xcd.3 (0.4) +0xc0| 00 | . | lame_ath_type: 0 0xcd.4-0xcd.7 (0.4) +0xc0| 00 | . | abr_vbr: 0 0xce-0xce.7 (1) +0xc0| 24| $| encoder_delay: 576 0xcf-0xd0.3 (1.4) +0xd0|05 |. | +0xd0|05 07 |.. | encoder_padding: 1287 0xd0.4-0xd1.7 (1.4) +0xd0| 00 | . | misc: 0 0xd2-0xd2.7 (1) +0xd0| 00 | . | mp3_gain: 0 0xd3-0xd3.7 (1) +0xd0| 00 00 | .. | preset: 0 0xd4-0xd5.7 (2) +0xd0| 00 00 02 57 | ...W | length: 599 0xd6-0xd9.7 (4) +0xd0| 62 f0 | b. | music_crc: 25328 0xda-0xdb.7 (2) +0xd0| 5a 35 | Z5 | tag_crc: 23093 0xdc-0xdd.7 (2) +mp3> ^D diff --git a/pkg/interp/testdata/options.fqtest b/pkg/interp/testdata/options.fqtest index c79726f29c..fb36f48543 100644 --- a/pkg/interp/testdata/options.fqtest +++ b/pkg/interp/testdata/options.fqtest @@ -1,6 +1,7 @@ $ fq -n options { "addrbase": 16, + "arraytruncate": 50, "bitsformat": "snippet", "bytecolors": "0-0xff=brightwhite,0=brightblack,32-126:9-13=white", "color": false, @@ -26,6 +27,10 @@ $ fq -o addrbase=10 -n options.addrbase 10 $ fq -o addrbase=true -n options.addrbase 16 +$ fq -o arraytruncate=10 -n options.arraytruncate +10 +$ fq -o arraytruncate=true -n options.arraytruncate +50 $ fq -o bitsformat=base64 -n options.bitsformat "base64" $ fq -o bytecolors=0-0xff=red -n options.bytecolors diff --git a/pkg/interp/testdata/value.fqtest b/pkg/interp/testdata/value.fqtest index 6a8a31085d..f6aa5b1eda 100644 --- a/pkg/interp/testdata/value.fqtest +++ b/pkg/interp/testdata/value.fqtest @@ -67,56 +67,7 @@ $ fq -d mp3 '.frames[0].xing | ., .frames, .toc, .header, .present_flags.toc, .m 0x80| a6 | . | [47]: 166 0x80| a6 | . | [48]: 166 0x80| a6 | . | [49]: 166 -0x80| ff | . | [50]: 255 -0x80| ff | . | [51]: 255 -0x80| ff | . | [52]: 255 -0x80| ff | . | [53]: 255 -0x80| ff | . | [54]: 255 -0x80| ff | . | [55]: 255 -0x80| ff | . | [56]: 255 -0x80| ff | . | [57]: 255 -0x80| ff | . | [58]: 255 -0x80| ff | . | [59]: 255 -0x80| ff | . | [60]: 255 -0x80| ff| .| [61]: 255 -0x90|ff |. | [62]: 255 -0x90| ff | . | [63]: 255 -0x90| ff | . | [64]: 255 -0x90| ff | . | [65]: 255 -0x90| ff | . | [66]: 255 -0x90| ff | . | [67]: 255 -0x90| ff | . | [68]: 255 -0x90| ff | . | [69]: 255 -0x90| ff | . | [70]: 255 -0x90| ff | . | [71]: 255 -0x90| ff | . | [72]: 255 -0x90| ff | . | [73]: 255 -0x90| ff | . | [74]: 255 -0x90| ff | . | [75]: 255 -0x90| ff | . | [76]: 255 -0x90| ff| .| [77]: 255 -0xa0|ff |. | [78]: 255 -0xa0| ff | . | [79]: 255 -0xa0| ff | . | [80]: 255 -0xa0| ff | . | [81]: 255 -0xa0| ff | . | [82]: 255 -0xa0| ff | . | [83]: 255 -0xa0| ff | . | [84]: 255 -0xa0| ff | . | [85]: 255 -0xa0| ff | . | [86]: 255 -0xa0| ff | . | [87]: 255 -0xa0| ff | . | [88]: 255 -0xa0| ff | . | [89]: 255 -0xa0| ff | . | [90]: 255 -0xa0| ff | . | [91]: 255 -0xa0| ff | . | [92]: 255 -0xa0| ff| .| [93]: 255 -0xb0|ff |. | [94]: 255 -0xb0| ff | . | [95]: 255 -0xb0| ff | . | [96]: 255 -0xb0| ff | . | [97]: 255 -0xb0| ff | . | [98]: 255 -0xb0| ff | . | [99]: 255 + | | | [50:99]: ... |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| | 0x40| 49 6e 66 6f | Info |.frames[0].xing.header: "Info" |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |