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

Merge pull request #583 from wader/help-cleanup

doc,fq: Improve cli help and some cleanup
This commit is contained in:
Mattias Wadman 2023-02-15 11:13:12 +01:00 committed by GitHub
commit 55375c0331
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 35 additions and 31 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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