mirror of
https://github.com/wader/fq.git
synced 2025-01-03 19:19:43 +03:00
doc,fq: Improve cli help and some cleanup
This commit is contained in:
parent
9bad37814e
commit
a1bb630a2a
@ -22,7 +22,7 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeBlkDat(d *decode.D, in interface{}) interface{} {
|
func decodeBlkDat(d *decode.D, in any) any {
|
||||||
validBlocks := 0
|
validBlocks := 0
|
||||||
for !d.End() {
|
for !d.End() {
|
||||||
d.FieldFormat("block", bitcoinBlockFormat, format.BitCoinBlockIn{HasHeader: true})
|
d.FieldFormat("block", bitcoinBlockFormat, format.BitCoinBlockIn{HasHeader: true})
|
||||||
|
@ -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)
|
bbi, _ := in.(format.BitCoinBlockIn)
|
||||||
size := d.BitsLeft()
|
size := d.BitsLeft()
|
||||||
|
|
||||||
|
@ -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
|
// based on https://en.bitcoin.it/wiki/Script
|
||||||
opcodeEntries := opcodeEntries{
|
opcodeEntries := opcodeEntries{
|
||||||
{r: [2]byte{0x00, 0x00}, s: scalar.Uint{Sym: "false"}},
|
{r: [2]byte{0x00, 0x00}, s: scalar.Uint{Sym: "false"}},
|
||||||
|
@ -44,7 +44,7 @@ func decodeVarInt(d *decode.D) uint64 {
|
|||||||
// all zero
|
// all zero
|
||||||
var txIDCoinbaseBytes = [32]byte{}
|
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.Endian = decode.LittleEndian
|
||||||
|
|
||||||
d.FieldU32("version")
|
d.FieldU32("version")
|
||||||
|
10
format/mp4/testdata/pssh.fqtest
vendored
10
format/mp4/testdata/pssh.fqtest
vendored
@ -112,7 +112,7 @@ $ fq ddv pssh.mp4
|
|||||||
| | | wire_type: "varint" (0) 0x49f-NA (0)
|
| | | wire_type: "varint" (0) 0x49f-NA (0)
|
||||||
0x490| 01| .| wire_value: 1 0x49f-0x49f.7 (1)
|
0x490| 01| .| wire_value: 1 0x49f-0x49f.7 (1)
|
||||||
| | | name: "algorithm" 0x4a0-NA (0)
|
| | | name: "algorithm" 0x4a0-NA (0)
|
||||||
| | | type: "Enum" 0x4a0-NA (0)
|
| | | type: "enum" 0x4a0-NA (0)
|
||||||
| | | enum: "aesctr" 0x4a0-NA (0)
|
| | | enum: "aesctr" 0x4a0-NA (0)
|
||||||
| | | [1]{}: field 0x4a0-0x4b1.7 (18)
|
| | | [1]{}: field 0x4a0-0x4b1.7 (18)
|
||||||
0x4a0|12 |. | key_n: 18 0x4a0-0x4a0.7 (1)
|
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)
|
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 |.. |
|
0x4b0|f8 a7 |.. |
|
||||||
| | | name: "key_id" 0x4b2-NA (0)
|
| | | name: "key_id" 0x4b2-NA (0)
|
||||||
| | | type: "Bytes" 0x4b2-NA (0)
|
| | | type: "bytes" 0x4b2-NA (0)
|
||||||
| | | value: raw bits 0x4b2-NA (0)
|
| | | value: raw bits 0x4b2-NA (0)
|
||||||
| | | [2]{}: field 0x4b2-0x4c0.7 (15)
|
| | | [2]{}: field 0x4b2-0x4c0.7 (15)
|
||||||
0x4b0| 1a | . | key_n: 26 0x4b2-0x4b2.7 (1)
|
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)
|
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 |
|
0x4c0|74 |t |
|
||||||
| | | name: "provider" 0x4c1-NA (0)
|
| | | name: "provider" 0x4c1-NA (0)
|
||||||
| | | type: "String" 0x4c1-NA (0)
|
| | | type: "string" 0x4c1-NA (0)
|
||||||
| | | value: "widevine_test" 0x4c1-NA (0)
|
| | | value: "widevine_test" 0x4c1-NA (0)
|
||||||
| | | [3]{}: field 0x4c1-0x4ca.7 (10)
|
| | | [3]{}: field 0x4c1-0x4ca.7 (10)
|
||||||
0x4c0| 22 | " | key_n: 34 0x4c1-0x4c1.7 (1)
|
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| 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)
|
0x4c0| 31 32 33 34 35 36 37 38 | 12345678 | wire_value: raw bits 0x4c3-0x4ca.7 (8)
|
||||||
| | | name: "content_id" 0x4cb-NA (0)
|
| | | name: "content_id" 0x4cb-NA (0)
|
||||||
| | | type: "Bytes" 0x4cb-NA (0)
|
| | | type: "bytes" 0x4cb-NA (0)
|
||||||
| | | value: raw bits 0x4cb-NA (0)
|
| | | value: raw bits 0x4cb-NA (0)
|
||||||
| | | [4]{}: field 0x4cb-0x4d3.7 (9)
|
| | | [4]{}: field 0x4cb-0x4d3.7 (9)
|
||||||
0x4c0| 32 | 2 | key_n: 50 0x4cb-0x4cb.7 (1)
|
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)
|
0x4c0| 64 65 66| def| wire_value: raw bits 0x4cd-0x4d3.7 (7)
|
||||||
0x4d0|61 75 6c 74| |ault| |
|
0x4d0|61 75 6c 74| |ault| |
|
||||||
| | | name: "policy" 0x4d4-NA (0)
|
| | | name: "policy" 0x4d4-NA (0)
|
||||||
| | | type: "String" 0x4d4-NA (0)
|
| | | type: "string" 0x4d4-NA (0)
|
||||||
| | | value: "default" 0x4d4-NA (0)
|
| | | value: "default" 0x4d4-NA (0)
|
||||||
|
@ -24,24 +24,24 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var ProtoBufTypeNames = scalar.UintMapSymStr{
|
var ProtoBufTypeNames = scalar.UintMapSymStr{
|
||||||
ProtoBufTypeInt32: "Int32",
|
ProtoBufTypeInt32: "int32",
|
||||||
ProtoBufTypeInt64: "Int64",
|
ProtoBufTypeInt64: "int64",
|
||||||
ProtoBufTypeUInt32: "UInt32",
|
ProtoBufTypeUInt32: "uint32",
|
||||||
ProtoBufTypeUInt64: "UInt64",
|
ProtoBufTypeUInt64: "uint64",
|
||||||
ProtoBufTypeSInt32: "SInt32",
|
ProtoBufTypeSInt32: "sint32",
|
||||||
ProtoBufTypeSInt64: "SInt64",
|
ProtoBufTypeSInt64: "sint64",
|
||||||
ProtoBufTypeBool: "Bool",
|
ProtoBufTypeBool: "bool",
|
||||||
ProtoBufTypeEnum: "Enum",
|
ProtoBufTypeEnum: "enum",
|
||||||
ProtoBufTypeFixed64: "Fixed64",
|
ProtoBufTypeFixed64: "fixed64",
|
||||||
ProtoBufTypeSFixed64: "SFixed64",
|
ProtoBufTypeSFixed64: "sfixed64",
|
||||||
ProtoBufTypeDouble: "Double",
|
ProtoBufTypeDouble: "double",
|
||||||
ProtoBufTypeString: "String",
|
ProtoBufTypeString: "string",
|
||||||
ProtoBufTypeBytes: "Bytes",
|
ProtoBufTypeBytes: "bytes",
|
||||||
ProtoBufTypeMessage: "Message",
|
ProtoBufTypeMessage: "message",
|
||||||
ProtoBufTypePackedRepeated: "PackedRepeated",
|
ProtoBufTypePackedRepeated: "packed_repeated",
|
||||||
ProtoBufTypeFixed32: "Fixed32",
|
ProtoBufTypeFixed32: "fixed32",
|
||||||
ProtoBufTypeSFixed32: "SFixed32",
|
ProtoBufTypeSFixed32: "sfixed32",
|
||||||
ProtoBufTypeFloat: "Float",
|
ProtoBufTypeFloat: "float",
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProtoBufField struct {
|
type ProtoBufField struct {
|
||||||
|
@ -130,7 +130,7 @@ func (err *ArrayIndexTooLargeError) Error() string {
|
|||||||
return fmt.Sprintf("array index too large: %v", err.V)
|
return fmt.Sprintf("array index too large: %v", err.V)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TypeErrorPreview(v interface{}) string {
|
func TypeErrorPreview(v any) string {
|
||||||
switch v.(type) {
|
switch v.(type) {
|
||||||
case nil:
|
case nil:
|
||||||
return "null"
|
return "null"
|
||||||
|
@ -25,7 +25,11 @@ def _tovalue($opts): empty;
|
|||||||
def open: empty;
|
def open: empty;
|
||||||
def scope: empty;
|
def scope: empty;
|
||||||
|
|
||||||
|
# TODO: some functions below are from format/* refactor somehow?
|
||||||
|
|
||||||
# used by help.jq
|
# used by help.jq
|
||||||
def to_jq: empty;
|
def to_jq: empty;
|
||||||
|
def markdown: empty;
|
||||||
|
def _markdown_to_text($width; $header_depth): empty;
|
||||||
# used by funcs.jq iprint
|
# used by funcs.jq iprint
|
||||||
def to_radix($base): empty;
|
def to_radix($base): empty;
|
||||||
|
@ -413,7 +413,7 @@ def _opt_cli_opts:
|
|||||||
"show_help": {
|
"show_help": {
|
||||||
short: "-h",
|
short: "-h",
|
||||||
long: "--help",
|
long: "--help",
|
||||||
description: "Show help for TOPIC (ex: --help, --help formats)",
|
description: "Show help for TOPIC (ex: --help, -h formats, -h mp4)",
|
||||||
string: "[TOPIC]",
|
string: "[TOPIC]",
|
||||||
optional: true
|
optional: true
|
||||||
},
|
},
|
||||||
|
2
pkg/interp/testdata/args.fqtest
vendored
2
pkg/interp/testdata/args.fqtest
vendored
@ -31,7 +31,7 @@ Example usages:
|
|||||||
--compact-output,-c Compact output
|
--compact-output,-c Compact output
|
||||||
--decode,-d NAME Decode format (probe)
|
--decode,-d NAME Decode format (probe)
|
||||||
--from-file,-f PATH Read EXPR from file
|
--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
|
--include-path,-L PATH Include search path
|
||||||
--join-output,-j No newline between outputs
|
--join-output,-j No newline between outputs
|
||||||
--monochrome-output,-M Force monochrome output
|
--monochrome-output,-M Force monochrome output
|
||||||
|
Loading…
Reference in New Issue
Block a user