mirror of
https://github.com/wader/fq.git
synced 2024-11-23 00:57:15 +03:00
interp: Use snake_case for all options
This commit is contained in:
parent
bf19588e35
commit
6ce4ba919b
@ -3,7 +3,7 @@
|
||||
- `format/0` overlap with jq builtin `format/1`. What to rename it to? `decode_format`?
|
||||
- repl expression returning a value that produced lots of output can't be interrupted. This is becaus ctrl-C currently only interrupts the evaluation of the expression, outputted value is printed (`display`) by parent.
|
||||
- Auto complete of non-global variables is broken. `scope` is broken for variables.
|
||||
- `tovalue({bitsformat: "base64"})` only affect root value.
|
||||
- `tovalue({bits_format: "base64"})` only affect root value.
|
||||
- Unknown field filling is currently only done on root, should be done per "framed" decode.
|
||||
- Sub buffers range is broken, could have a different size in parent (ex: compressed).
|
||||
- Symbolic values should be more intuitive, should not need to use ._symbol.
|
||||
|
@ -302,7 +302,7 @@ func dumpEx(v *decode.Value, buf []byte, cw *columnwriter.Writer, depth int, roo
|
||||
|
||||
cfmt(colAddr, "%s%s\n", rootIndent, deco.DumpAddr.F("*"))
|
||||
cprint(colHex, "\n")
|
||||
// TODO: truncate if displaybytes is small?
|
||||
// TODO: truncate if display_bytes is small?
|
||||
cfmt(colHex, "until %s%s (%s)",
|
||||
num.Bits(stopBit).StringByteBits(opts.AddrBase),
|
||||
isEnd,
|
||||
|
@ -838,7 +838,7 @@ 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 {
|
||||
if v, ok := m["array_truncate"]; ok {
|
||||
d.ArrayTruncate = num.MaxInt(0, toIntZ(v))
|
||||
}
|
||||
if v, ok := m["verbose"]; ok {
|
||||
@ -853,7 +853,7 @@ func mapSetOptions(d *Options, m map[string]interface{}) {
|
||||
if v, ok := m["colors"]; ok {
|
||||
d.Colors = toStringZ(v)
|
||||
}
|
||||
if v, ok := m["bytecolors"]; ok {
|
||||
if v, ok := m["byte_colors"]; ok {
|
||||
d.ByteColors = toStringZ(v)
|
||||
}
|
||||
if v, ok := m["unicode"]; ok {
|
||||
@ -874,14 +874,14 @@ func mapSetOptions(d *Options, m map[string]interface{}) {
|
||||
if v, ok := m["compact"]; ok {
|
||||
d.Compact = toBoolZ(v)
|
||||
}
|
||||
if v, ok := m["bitsformat"]; ok {
|
||||
if v, ok := m["bits_format"]; ok {
|
||||
d.BitsFormat = toStringZ(v)
|
||||
}
|
||||
|
||||
if v, ok := m["linebytes"]; ok {
|
||||
if v, ok := m["line_bytes"]; ok {
|
||||
d.LineBytes = num.MaxInt(0, toIntZ(v))
|
||||
}
|
||||
if v, ok := m["displaybytes"]; ok {
|
||||
if v, ok := m["display_bytes"]; ok {
|
||||
d.DisplayBytes = num.MaxInt(0, toIntZ(v))
|
||||
}
|
||||
if v, ok := m["addrbase"]; ok {
|
||||
|
@ -38,9 +38,9 @@ def _build_default_options:
|
||||
addrbase: 16,
|
||||
arg: [],
|
||||
argjson: [],
|
||||
arraytruncate: 50,
|
||||
bitsformat: "snippet",
|
||||
bytecolors: "0-0xff=brightwhite,0=brightblack,32-126:9-13=white",
|
||||
array_truncate: 50,
|
||||
bits_format: "snippet",
|
||||
byte_colors: "0-0xff=brightwhite,0=brightblack,32-126:9-13=white",
|
||||
color: ($stdout.is_terminal and (env.NO_COLOR | . == null or . == "")),
|
||||
colors: (
|
||||
{
|
||||
@ -65,14 +65,14 @@ def _build_default_options:
|
||||
decode_progress: (env.NO_DECODE_PROGRESS == null),
|
||||
depth: 0,
|
||||
# TODO: intdiv 2 * 2 to get even number, nice or maybe not needed?
|
||||
displaybytes: (if $stdout.is_terminal then [intdiv(intdiv($stdout.width; 8); 2) * 2, 4] | max else 16 end),
|
||||
display_bytes: (if $stdout.is_terminal then [intdiv(intdiv($stdout.width; 8); 2) * 2, 4] | max else 16 end),
|
||||
expr: ".",
|
||||
expr_file: null,
|
||||
expr_eval_path: "arg",
|
||||
filenames: ["-"],
|
||||
include_path: null,
|
||||
join_string: "\n",
|
||||
linebytes: (if $stdout.is_terminal then [intdiv(intdiv($stdout.width; 8); 2) * 2, 4] | max else 16 end),
|
||||
line_bytes: (if $stdout.is_terminal then [intdiv(intdiv($stdout.width; 8); 2) * 2, 4] | max else 16 end),
|
||||
null_input: false,
|
||||
rawfile: [],
|
||||
raw_output: ($stdout.is_terminal | not),
|
||||
@ -127,9 +127,9 @@ def _to_options:
|
||||
addrbase: (.addrbase | _tonumber),
|
||||
arg: (.arg | _toarray(_is_string_pair)),
|
||||
argjson: (.argjson | _toarray(_is_string_pair)),
|
||||
arraytruncate: (.arraytruncate | _tonumber),
|
||||
bitsformat: (.bitsformat | _tostring),
|
||||
bytecolors: (.bytecolors | _tostring),
|
||||
array_truncate: (.array_truncate | _tonumber),
|
||||
bits_format: (.bits_format | _tostring),
|
||||
byte_colors: (.byte_colors | _tostring),
|
||||
color: (.color | _toboolean),
|
||||
colors: (.colors | _tostring),
|
||||
compact: (.compact | _toboolean),
|
||||
@ -137,13 +137,13 @@ def _to_options:
|
||||
decode_format: (.decode_format | _tostring),
|
||||
decode_progress: (.decode_progress | _toboolean),
|
||||
depth: (.depth | _tonumber),
|
||||
displaybytes: (.displaybytes | _tonumber),
|
||||
display_bytes: (.display_bytes | _tonumber),
|
||||
expr: (.expr | _tostring),
|
||||
expr_file: (.expr_file | _tostring),
|
||||
filename: (.filenames | _toarray(type == "string")),
|
||||
include_path: (.include_path | _tostring),
|
||||
join_string: (.join_string | _tostring),
|
||||
linebytes: (.linebytes | _tonumber),
|
||||
line_bytes: (.line_bytes | _tonumber),
|
||||
null_input: (.null_input | _toboolean),
|
||||
rawfile: (.rawfile| _toarray(_is_string_pair)),
|
||||
raw_output: (.raw_output | _toboolean),
|
||||
@ -409,11 +409,11 @@ def display($opts): _display($opts);
|
||||
def display: _display({});
|
||||
def d($opts): _display($opts);
|
||||
def d: _display({});
|
||||
def full($opts): _display({arraytruncate: 0} + $opts);
|
||||
def full($opts): _display({array_truncate: 0} + $opts);
|
||||
def full: full({});
|
||||
def f($opts): full($opts);
|
||||
def f: full;
|
||||
def verbose($opts): _display({verbose: true, arraytruncate: 0} + $opts);
|
||||
def verbose($opts): _display({verbose: true, array_truncate: 0} + $opts);
|
||||
def verbose: verbose({});
|
||||
def v($opts): verbose($opts);
|
||||
def v: verbose;
|
||||
|
10
pkg/interp/testdata/args.fqtest
vendored
10
pkg/interp/testdata/args.fqtest
vendored
@ -122,9 +122,9 @@ $ fq --options
|
||||
"addrbase": 16,
|
||||
"arg": [],
|
||||
"argjson": [],
|
||||
"arraytruncate": 50,
|
||||
"bitsformat": "snippet",
|
||||
"bytecolors": "0-0xff=brightwhite,0=brightblack,32-126:9-13=white",
|
||||
"array_truncate": 50,
|
||||
"bits_format": "snippet",
|
||||
"byte_colors": "0-0xff=brightwhite,0=brightblack,32-126:9-13=white",
|
||||
"color": false,
|
||||
"colors": "array=white,dumpaddr=yellow,dumpheader=yellow+underline,error=brightred,false=yellow,index=white,null=brightblack,number=cyan,object=white,objectkey=brightblue,string=green,true=yellow,value=white",
|
||||
"compact": false,
|
||||
@ -132,7 +132,7 @@ $ fq --options
|
||||
"decode_format": "probe",
|
||||
"decode_progress": false,
|
||||
"depth": 0,
|
||||
"displaybytes": 16,
|
||||
"display_bytes": 16,
|
||||
"expr": ".",
|
||||
"expr_eval_path": "arg",
|
||||
"expr_file": null,
|
||||
@ -141,7 +141,7 @@ $ fq --options
|
||||
],
|
||||
"include_path": null,
|
||||
"join_string": "\n",
|
||||
"linebytes": 16,
|
||||
"line_bytes": 16,
|
||||
"null_input": false,
|
||||
"raw_output": false,
|
||||
"raw_string": false,
|
||||
|
2
pkg/interp/testdata/buffer.fqtest
vendored
2
pkg/interp/testdata/buffer.fqtest
vendored
@ -36,7 +36,7 @@ $ fq -d mp3 '.frames[]._bits[0:12] | tonumber' /test.mp3
|
||||
4095
|
||||
$ fq -d mp3 '.headers[0].magic._bits[0:24] | tostring' /test.mp3
|
||||
"ID3"
|
||||
$ fq -d mp3 '.frames[0].padding | ("", "md5", "base64", "snippet") as $f | tovalue({bitsformat: $f})' /test.mp3
|
||||
$ fq -d mp3 '.frames[0].padding | ("", "md5", "base64", "snippet") as $f | tovalue({bits_format: $f})' /test.mp3
|
||||
"<5>AAAAAAA="
|
||||
"ca9c491ac66b2c62500882e93f3719a8"
|
||||
"AAAAAAA="
|
||||
|
4
pkg/interp/testdata/display.fqtest
vendored
4
pkg/interp/testdata/display.fqtest
vendored
@ -25,7 +25,7 @@ mp3> display({depth: 2})
|
||||
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]
|
||||
mp3> display({depth: 1, displaybytes: 8})
|
||||
mp3> display({depth: 1, display_bytes: 8})
|
||||
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.: {} /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) | |
|
||||
@ -33,7 +33,7 @@ mp3> display({depth: 1, displaybytes: 8})
|
||||
0x030|c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................|
|
||||
* |until 0x283.7 (end) (599) | |
|
||||
| | | footers: [0]
|
||||
mp3> display({depth: 1, linebytes: 8})
|
||||
mp3> display({depth: 1, line_bytes: 8})
|
||||
|00 01 02 03 04 05 06 07|01234567|.: {} /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..|
|
||||
|
24
pkg/interp/testdata/options.fqtest
vendored
24
pkg/interp/testdata/options.fqtest
vendored
@ -3,9 +3,9 @@ $ fq -n options
|
||||
"addrbase": 16,
|
||||
"arg": [],
|
||||
"argjson": [],
|
||||
"arraytruncate": 50,
|
||||
"bitsformat": "snippet",
|
||||
"bytecolors": "0-0xff=brightwhite,0=brightblack,32-126:9-13=white",
|
||||
"array_truncate": 50,
|
||||
"bits_format": "snippet",
|
||||
"byte_colors": "0-0xff=brightwhite,0=brightblack,32-126:9-13=white",
|
||||
"color": false,
|
||||
"colors": "array=white,dumpaddr=yellow,dumpheader=yellow+underline,error=brightred,false=yellow,index=white,null=brightblack,number=cyan,object=white,objectkey=brightblue,string=green,true=yellow,value=white",
|
||||
"compact": false,
|
||||
@ -13,7 +13,7 @@ $ fq -n options
|
||||
"decode_format": "probe",
|
||||
"decode_progress": false,
|
||||
"depth": 0,
|
||||
"displaybytes": 16,
|
||||
"display_bytes": 16,
|
||||
"expr": "options",
|
||||
"expr_eval_path": "arg",
|
||||
"expr_file": null,
|
||||
@ -22,7 +22,7 @@ $ fq -n options
|
||||
],
|
||||
"include_path": null,
|
||||
"join_string": "\n",
|
||||
"linebytes": 16,
|
||||
"line_bytes": 16,
|
||||
"null_input": true,
|
||||
"raw_output": false,
|
||||
"raw_string": false,
|
||||
@ -41,13 +41,13 @@ $ fq -o addrbase=10 -n options.addrbase
|
||||
10
|
||||
$ fq -o addrbase=true -n options.addrbase
|
||||
16
|
||||
$ fq -o arraytruncate=10 -n options.arraytruncate
|
||||
$ fq -o array_truncate=10 -n options.array_truncate
|
||||
10
|
||||
$ fq -o arraytruncate=true -n options.arraytruncate
|
||||
$ fq -o array_truncate=true -n options.array_truncate
|
||||
50
|
||||
$ fq -o bitsformat=base64 -n options.bitsformat
|
||||
$ fq -o bits_format=base64 -n options.bits_format
|
||||
"base64"
|
||||
$ fq -o bytecolors=0-0xff=red -n options.bytecolors
|
||||
$ fq -o byte_colors=0-0xff=red -n options.byte_colors
|
||||
"0-0xff=red"
|
||||
$ fq -o color=10 -n options.color
|
||||
[33mtrue[m
|
||||
@ -67,9 +67,9 @@ $ fq -o depth=10 -n options.depth
|
||||
10
|
||||
$ fq -o depth=true -n options.depth
|
||||
0
|
||||
$ fq -o displaybytes=10 -n options.displaybytes
|
||||
$ fq -o display_bytes=10 -n options.display_bytes
|
||||
10
|
||||
$ fq -o displaybytes=true -n options.displaybytes
|
||||
$ fq -o display_bytes=true -n options.display_bytes
|
||||
16
|
||||
$ fq -o expr_file=test.jq -n options.expr_file
|
||||
exitcode: 2
|
||||
@ -79,7 +79,7 @@ $ fq -o include_path=path -n options.include_path
|
||||
"path"
|
||||
$ fq -o join_string=aaa\n -n options.join_string
|
||||
"aaa\n"aaa
|
||||
$ fq -o linebytes=true -n options.linebytes
|
||||
$ fq -o line_bytes=true -n options.line_bytes
|
||||
16
|
||||
$ fq -o null_input=true -n options.null_input
|
||||
true
|
||||
|
Loading…
Reference in New Issue
Block a user