diff --git a/format/bitcoin/bitcoin_blkdat.go b/format/bitcoin/bitcoin_blkdat.go index 6aa05b58..2530c251 100644 --- a/format/bitcoin/bitcoin_blkdat.go +++ b/format/bitcoin/bitcoin_blkdat.go @@ -22,7 +22,7 @@ func init() { }) } -func decodeBlkDat(d *decode.D, in interface{}) interface{} { +func decodeBlkDat(d *decode.D, in any) any { validBlocks := 0 for !d.End() { d.FieldFormat("block", bitcoinBlockFormat, format.BitCoinBlockIn{HasHeader: true}) diff --git a/format/bitcoin/bitcoin_block.go b/format/bitcoin/bitcoin_block.go index fb064205..9decdf0c 100644 --- a/format/bitcoin/bitcoin_block.go +++ b/format/bitcoin/bitcoin_block.go @@ -35,7 +35,7 @@ var rawHexReverse = scalar.BitBufFn(func(s scalar.BitBuf) (scalar.BitBuf, error) }) }) -func decodeBitcoinBlock(d *decode.D, in interface{}) interface{} { +func decodeBitcoinBlock(d *decode.D, in any) any { bbi, _ := in.(format.BitCoinBlockIn) size := d.BitsLeft() diff --git a/format/bitcoin/bitcoin_script.go b/format/bitcoin/bitcoin_script.go index 67d74e1a..b0d2db2f 100644 --- a/format/bitcoin/bitcoin_script.go +++ b/format/bitcoin/bitcoin_script.go @@ -43,7 +43,7 @@ func init() { }) } -func decodeBitcoinScript(d *decode.D, in interface{}) interface{} { +func decodeBitcoinScript(d *decode.D, in any) any { // based on https://en.bitcoin.it/wiki/Script opcodeEntries := opcodeEntries{ {r: [2]byte{0x00, 0x00}, s: scalar.Uint{Sym: "false"}}, diff --git a/format/bitcoin/bitcoin_transaction.go b/format/bitcoin/bitcoin_transaction.go index 2bb88500..71fe90ca 100644 --- a/format/bitcoin/bitcoin_transaction.go +++ b/format/bitcoin/bitcoin_transaction.go @@ -44,7 +44,7 @@ func decodeVarInt(d *decode.D) uint64 { // all zero var txIDCoinbaseBytes = [32]byte{} -func decodeBitcoinTranscation(d *decode.D, in interface{}) interface{} { +func decodeBitcoinTranscation(d *decode.D, in any) any { d.Endian = decode.LittleEndian d.FieldU32("version") diff --git a/format/mp4/testdata/pssh.fqtest b/format/mp4/testdata/pssh.fqtest index c8b1e839..54b22f22 100644 --- a/format/mp4/testdata/pssh.fqtest +++ b/format/mp4/testdata/pssh.fqtest @@ -112,7 +112,7 @@ $ fq ddv pssh.mp4 | | | wire_type: "varint" (0) 0x49f-NA (0) 0x490| 01| .| wire_value: 1 0x49f-0x49f.7 (1) | | | name: "algorithm" 0x4a0-NA (0) - | | | type: "Enum" 0x4a0-NA (0) + | | | type: "enum" 0x4a0-NA (0) | | | enum: "aesctr" 0x4a0-NA (0) | | | [1]{}: field 0x4a0-0x4b1.7 (18) 0x4a0|12 |. | key_n: 18 0x4a0-0x4a0.7 (1) @@ -122,7 +122,7 @@ $ fq ddv pssh.mp4 0x4a0| 88 37 80 c4 a9 81 49 4c b9 94 9e 93 79 2f| .7....IL....y/| wire_value: raw bits 0x4a2-0x4b1.7 (16) 0x4b0|f8 a7 |.. | | | | name: "key_id" 0x4b2-NA (0) - | | | type: "Bytes" 0x4b2-NA (0) + | | | type: "bytes" 0x4b2-NA (0) | | | value: raw bits 0x4b2-NA (0) | | | [2]{}: field 0x4b2-0x4c0.7 (15) 0x4b0| 1a | . | key_n: 26 0x4b2-0x4b2.7 (1) @@ -132,7 +132,7 @@ $ fq ddv pssh.mp4 0x4b0| 77 69 64 65 76 69 6e 65 5f 74 65 73| widevine_tes| wire_value: raw bits 0x4b4-0x4c0.7 (13) 0x4c0|74 |t | | | | name: "provider" 0x4c1-NA (0) - | | | type: "String" 0x4c1-NA (0) + | | | type: "string" 0x4c1-NA (0) | | | value: "widevine_test" 0x4c1-NA (0) | | | [3]{}: field 0x4c1-0x4ca.7 (10) 0x4c0| 22 | " | key_n: 34 0x4c1-0x4c1.7 (1) @@ -141,7 +141,7 @@ $ fq ddv pssh.mp4 0x4c0| 08 | . | length: 8 0x4c2-0x4c2.7 (1) 0x4c0| 31 32 33 34 35 36 37 38 | 12345678 | wire_value: raw bits 0x4c3-0x4ca.7 (8) | | | name: "content_id" 0x4cb-NA (0) - | | | type: "Bytes" 0x4cb-NA (0) + | | | type: "bytes" 0x4cb-NA (0) | | | value: raw bits 0x4cb-NA (0) | | | [4]{}: field 0x4cb-0x4d3.7 (9) 0x4c0| 32 | 2 | key_n: 50 0x4cb-0x4cb.7 (1) @@ -151,5 +151,5 @@ $ fq ddv pssh.mp4 0x4c0| 64 65 66| def| wire_value: raw bits 0x4cd-0x4d3.7 (7) 0x4d0|61 75 6c 74| |ault| | | | | name: "policy" 0x4d4-NA (0) - | | | type: "String" 0x4d4-NA (0) + | | | type: "string" 0x4d4-NA (0) | | | value: "default" 0x4d4-NA (0) diff --git a/format/shared.go b/format/shared.go index 8431522c..7e171619 100644 --- a/format/shared.go +++ b/format/shared.go @@ -24,24 +24,24 @@ const ( ) var ProtoBufTypeNames = scalar.UintMapSymStr{ - ProtoBufTypeInt32: "Int32", - ProtoBufTypeInt64: "Int64", - ProtoBufTypeUInt32: "UInt32", - ProtoBufTypeUInt64: "UInt64", - ProtoBufTypeSInt32: "SInt32", - ProtoBufTypeSInt64: "SInt64", - ProtoBufTypeBool: "Bool", - ProtoBufTypeEnum: "Enum", - ProtoBufTypeFixed64: "Fixed64", - ProtoBufTypeSFixed64: "SFixed64", - ProtoBufTypeDouble: "Double", - ProtoBufTypeString: "String", - ProtoBufTypeBytes: "Bytes", - ProtoBufTypeMessage: "Message", - ProtoBufTypePackedRepeated: "PackedRepeated", - ProtoBufTypeFixed32: "Fixed32", - ProtoBufTypeSFixed32: "SFixed32", - ProtoBufTypeFloat: "Float", + ProtoBufTypeInt32: "int32", + ProtoBufTypeInt64: "int64", + ProtoBufTypeUInt32: "uint32", + ProtoBufTypeUInt64: "uint64", + ProtoBufTypeSInt32: "sint32", + ProtoBufTypeSInt64: "sint64", + ProtoBufTypeBool: "bool", + ProtoBufTypeEnum: "enum", + ProtoBufTypeFixed64: "fixed64", + ProtoBufTypeSFixed64: "sfixed64", + ProtoBufTypeDouble: "double", + ProtoBufTypeString: "string", + ProtoBufTypeBytes: "bytes", + ProtoBufTypeMessage: "message", + ProtoBufTypePackedRepeated: "packed_repeated", + ProtoBufTypeFixed32: "fixed32", + ProtoBufTypeSFixed32: "sfixed32", + ProtoBufTypeFloat: "float", } type ProtoBufField struct { diff --git a/internal/gojqex/error.go b/internal/gojqex/error.go index 41727a2b..39ce677d 100644 --- a/internal/gojqex/error.go +++ b/internal/gojqex/error.go @@ -130,7 +130,7 @@ func (err *ArrayIndexTooLargeError) Error() string { return fmt.Sprintf("array index too large: %v", err.V) } -func TypeErrorPreview(v interface{}) string { +func TypeErrorPreview(v any) string { switch v.(type) { case nil: return "null" diff --git a/pkg/interp/.jq-lsp.jq b/pkg/interp/.jq-lsp.jq index 2398c4a1..b029801c 100644 --- a/pkg/interp/.jq-lsp.jq +++ b/pkg/interp/.jq-lsp.jq @@ -25,7 +25,11 @@ def _tovalue($opts): empty; def open: empty; def scope: empty; +# TODO: some functions below are from format/* refactor somehow? + # used by help.jq def to_jq: empty; +def markdown: empty; +def _markdown_to_text($width; $header_depth): empty; # used by funcs.jq iprint -def to_radix($base): empty; \ No newline at end of file +def to_radix($base): empty; diff --git a/pkg/interp/options.jq b/pkg/interp/options.jq index cfd9c308..0de21994 100644 --- a/pkg/interp/options.jq +++ b/pkg/interp/options.jq @@ -413,7 +413,7 @@ def _opt_cli_opts: "show_help": { short: "-h", long: "--help", - description: "Show help for TOPIC (ex: --help, --help formats)", + description: "Show help for TOPIC (ex: --help, -h formats, -h mp4)", string: "[TOPIC]", optional: true }, diff --git a/pkg/interp/testdata/args.fqtest b/pkg/interp/testdata/args.fqtest index 62617f9b..2aa6f920 100644 --- a/pkg/interp/testdata/args.fqtest +++ b/pkg/interp/testdata/args.fqtest @@ -31,7 +31,7 @@ Example usages: --compact-output,-c Compact output --decode,-d NAME Decode format (probe) --from-file,-f PATH Read EXPR from file ---help,-h [TOPIC] Show help for TOPIC (ex: --help, --help formats) +--help,-h [TOPIC] Show help for TOPIC (ex: --help, -h formats, -h mp4) --include-path,-L PATH Include search path --join-output,-j No newline between outputs --monochrome-output,-M Force monochrome output