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

Compare commits

...

28 Commits

Author SHA1 Message Date
Mattias Wadman
d4678016bf
Merge e9226226d3 into 1ec9748046 2024-05-16 08:41:06 +00:00
Mattias Wadman
e9226226d3 bits: Add from_f32le, to_f32le, ...
TODO:
- show somehow generalize to/from encodings?
- move code to somwewhere else?
2024-05-16 10:40:54 +02:00
Mattias Wadman
1ec9748046
Merge pull request #947 from wader/bump-make-golangci-lint-1.58.1
Update make-golangci-lint to 1.58.1 from 1.58.0
2024-05-09 18:12:49 +02:00
Mattias Wadman
2e5514fc50
Merge pull request #948 from wader/bump-github-golangci-lint-1.58.1
Update github-golangci-lint to 1.58.1 from 1.58.0
2024-05-09 18:12:44 +02:00
bump
a59ba2a2fa Update github-golangci-lint to 1.58.1 from 1.58.0
Release notes https://github.com/golangci/golangci-lint/releases/tag/v1.58.1
2024-05-09 16:03:55 +00:00
bump
7714fcf423 Update make-golangci-lint to 1.58.1 from 1.58.0
Release notes https://github.com/golangci/golangci-lint/releases/tag/v1.58.1
2024-05-09 16:03:52 +00:00
Mattias Wadman
544cf4cc09
Merge pull request #945 from wader/bump-docker-golang-1.22.3
Update docker-golang to 1.22.3 from 1.22.2
2024-05-09 00:01:16 +02:00
Mattias Wadman
25ad5f1c8f
Merge pull request #946 from wader/bump-github-go-version-1.22.3
Update github-go-version to 1.22.3 from 1.22.2
2024-05-09 00:00:41 +02:00
bump
9ff7da12a7 Update github-go-version to 1.22.3 from 1.22.2 2024-05-08 16:03:46 +00:00
bump
94cfbc670c Update docker-golang to 1.22.3 from 1.22.2 2024-05-08 16:03:44 +00:00
Mattias Wadman
163b3b609c
Merge pull request #944 from wader/bump-gomod-golang-x-net-0.25.0
Update gomod-golang-x-net to 0.25.0 from 0.24.0
2024-05-07 18:31:45 +02:00
bump
cabb67e8ab Update gomod-golang-x-net to 0.25.0 from 0.24.0
Tags https://github.com/golang/net/tags
2024-05-07 16:03:50 +00:00
Mattias Wadman
64df8bdbf5
Merge pull request #943 from wader/bump-gomod-golang-x-crypto-0.23.0
Update gomod-golang-x-crypto to 0.23.0 from 0.22.0
2024-05-06 19:16:07 +02:00
Mattias Wadman
481ac91880
Merge pull request #942 from wader/bump-gomod-ergochat-readline-0.1.1
Update gomod-ergochat-readline to 0.1.1 from 0.1.0
2024-05-06 19:15:51 +02:00
bump
14ada50806 Update gomod-golang-x-crypto to 0.23.0 from 0.22.0
Tags https://github.com/golang/crypto/tags
2024-05-06 16:04:45 +00:00
bump
12f332064c Update gomod-ergochat-readline to 0.1.1 from 0.1.0
Release notes https://github.com/ergochat/readline/releases/tag/v0.1.1
2024-05-06 16:04:43 +00:00
Mattias Wadman
0ff3e53c5f
Merge pull request #941 from wader/bump-gomod-golang-x-term-0.20.0
Update gomod-golang-x-term to 0.20.0 from 0.19.0
2024-05-05 18:16:15 +02:00
bump
586cf142e5 Update gomod-golang-x-term to 0.20.0 from 0.19.0
Tags https://github.com/golang/term/tags
2024-05-05 16:03:41 +00:00
Mattias Wadman
fb20db5eb7
Merge pull request #937 from wader/bump-make-golangci-lint-1.58.0
Update make-golangci-lint to 1.58.0 from 1.57.2
2024-05-04 18:15:24 +02:00
Mattias Wadman
48868bd4ee
Merge pull request #939 from wader/bump-github-golangci-lint-1.58.0
Update github-golangci-lint to 1.58.0 from 1.57.2
2024-05-04 18:12:55 +02:00
Mattias Wadman
c5c8b75c56
Merge pull request #938 from wader/bump-gomod-golang/text-0.15.0
Update gomod-golang/text to 0.15.0 from 0.14.0
2024-05-04 18:12:01 +02:00
bump
a5de74cd23 Update github-golangci-lint to 1.58.0 from 1.57.2
Release notes https://github.com/golangci/golangci-lint/releases/tag/v1.58.0
2024-05-04 16:03:51 +00:00
bump
42730d7586 Update gomod-golang/text to 0.15.0 from 0.14.0
Source diff 0.14.0..0.15.0 https://github.com/golang/text/compare/v0.14.0..v0.15.0
2024-05-04 16:03:49 +00:00
bump
3a683b64f8 Update make-golangci-lint to 1.58.0 from 1.57.2
Release notes https://github.com/golangci/golangci-lint/releases/tag/v1.58.0
2024-05-04 16:03:46 +00:00
Mattias Wadman
496849daa5
Merge pull request #936 from wader/update-docs
doc: Cleanup and improve texts a bit
2024-04-30 14:25:36 +02:00
Mattias Wadman
ebf063d1c0 doc: Cleanup and improve texts a bit 2024-04-30 14:16:13 +02:00
Mattias Wadman
b8eec4078f
Merge pull request #934 from matmat/dht-patch
jpeg: Add parsing of DHT parameters
2024-04-25 13:29:44 +02:00
Mattias Iko Mattsson
6e13b4b550 jpeg: Add parsing of DHT parameters 2024-04-25 13:17:08 +02:00
14 changed files with 201 additions and 50 deletions

View File

@ -7,7 +7,7 @@ on:
pull_request:
env:
GOLANGCILINT_VERSION: "1.57.2"
GOLANGCILINT_VERSION: "1.58.1"
jobs:
lint:
@ -15,7 +15,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: "1.22.2"
go-version: "1.22.3"
- uses: actions/checkout@v3
- uses: golangci/golangci-lint-action@v3
with:
@ -47,7 +47,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "1.22.2"
go-version: "1.22.3"
- name: Test
env:
GOARCH: ${{ matrix.goarch }}

View File

@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "1.22.2"
go-version: "1.22.3"
- uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser

View File

@ -1,5 +1,5 @@
# bump: docker-golang /FROM golang:([\d.]+)/ docker:golang|^1
FROM golang:1.22.2-bookworm AS base
FROM golang:1.22.3-bookworm AS base
# expect is used to test cli
RUN \

View File

@ -61,7 +61,7 @@ gogenerate: always
lint: always
# bump: make-golangci-lint /golangci-lint@v([\d.]+)/ git:https://github.com/golangci/golangci-lint.git|^1
# bump: make-golangci-lint link "Release notes" https://github.com/golangci/golangci-lint/releases/tag/v$LATEST
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2 run
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.58.1 run
depgraph.svg: always
go run github.com/kisielk/godepgraph@latest github.com/wader/fq | dot -Tsvg -o godepgraph.svg

View File

@ -2,25 +2,23 @@
Tool, language and decoders for working with binary data.
TLDR: it aims to be jq, hexdump, dd and gdb for files combined into one.
![fq demo](doc/demo.svg)
Basic usage is `fq . file` or `fq d file`.
Basic usage is `fq . file`, `fq d file` or `fq 'some query' file ...`.
For details see [usage.md](doc/usage.md).
### Background
fq is inspired by the well known jq tool and language that allows you to work with binary formats the same way you would using jq. In addition it can present data like a hex viewer, transform, slice and concatenate binary data. It also supports nested formats and has an interactive REPL with auto-completion.
fq is inspired by the [jq](https://jqlang.github.io/jq/) tool and language and allows you to work with binary formats in the same way. In addition to using jq expressions it can also present decoded tree structures, transform, slice and concatenate binary data. It also supports nested formats and features an interactive REPL with auto-completion of functions and names.
It was originally designed to query, inspect and debug media codecs and containers like mp4, flac, mp3, jpeg. But since then it has been extended to support a variety of formats like executables, packet captures (with TCP reassembly) and serialization formats like JSON, YAML, XML, ASN1 BER, Avro, CBOR, protobuf. In addition it also has functions to work with URLs, convert to/from hex, number bases, search for things etc.
In summary it aims to be jq, hexdump, dd and gdb for files combined into one.
**NOTE:** fq is still early in development so things might change, be broken or do not make sense. That also means that there is a great opportunity to help out!
It was originally designed to query, inspect and debug media codecs and containers like MP4, FLAC and JPEG but has since been extended to support a variety of formats like executables, packet captures (with TCP reassembly) and serialization formats like JSON, YAML, XML, CBOR, protobuf. In addition it also has functions to work with URLs, convert to/from hex, number bases, search for patterns etc.
### Goals
- Make binaries accessible, queryable and sliceable.
- Make binaries more accessible, queryable and sliceable.
- Nested formats and bit-oriented decoding.
- Quick and comfortable CLI tool.
- Bits and bytes transformations.
@ -243,7 +241,7 @@ apk add -X http://dl-cdn.alpinelinux.org/alpine/edge/testing fq
Make sure you have [go](https://go.dev) 1.20 or later installed.
To install directly from git repository (no clone needed):
To install directly from git repository (no git clone needed):
```sh
# build and install latest release
go install github.com/wader/fq@latest
@ -267,10 +265,6 @@ go build -o fq .
make test fq
```
## TODO and ideas
See [TODO.md](doc/TODO.md)
## Development and adding a new decoder
See [dev.md](doc/dev.md)
@ -306,6 +300,10 @@ for inventing the [jq](https://github.com/stedolan/jq) language.
- [Sustainability of Digital Formats](https://www.loc.gov/preservation/digital/formats/) at Library of Congress.
- [Data Format Description Language (DFDL)](https://en.wikipedia.org/wiki/Data_Format_Description_Language).
## TODO and ideas
See [TODO.md](doc/TODO.md)
## License
`fq` is distributed under the terms of the MIT License.

View File

@ -236,8 +236,8 @@ make test
go test ./...
# run all tests for one format
go test -run TestFormats/mp4 ./format/
# update all actual outputs in tests
go test ./... -update
# update all expected outputs for tests
go test ./pkg/interp ./format -update
# update actual output for specific tests
go run ./format -run TestFormats/elf -update
# color diff

View File

@ -2,14 +2,21 @@ package bits
import (
"embed"
"encoding/binary"
"fmt"
"math"
"github.com/wader/fq/format"
"github.com/wader/fq/internal/gojqx"
"github.com/wader/fq/internal/mathx"
"github.com/wader/fq/pkg/bitio"
"github.com/wader/fq/pkg/decode"
"github.com/wader/fq/pkg/interp"
"github.com/wader/fq/pkg/scalar"
)
//go:embed bits.md
//go:embed bits.jq
//go:embed bytes.md
var bitsFS embed.FS
@ -39,5 +46,74 @@ func init() {
DecodeFn: decodeBits(8),
SkipDecodeFunction: true, // skip add bytes and frombytes function
})
interp.RegisterFunc2("_from_float", func(_ *interp.Interp, c any, nBits int, isLE bool) any {
switch nBits {
case 16, 32, 64:
default:
return fmt.Errorf("unsupported bit size %d, must be 16, 32 or 64", nBits)
}
br, err := interp.ToBitReader(c)
if err != nil {
return err
}
var b [8]byte
bs := b[:][0 : nBits/8]
_, err = br.ReadBits(bs[:], int64(nBits))
if err != nil {
return err
}
if isLE {
decode.ReverseBytes(bs[:])
}
switch nBits {
case 64:
return math.Float64frombits(binary.BigEndian.Uint64(bs[:]))
case 32:
return float64(math.Float32frombits(binary.BigEndian.Uint32(bs[:])))
case 16:
return float64(mathx.Float16(binary.BigEndian.Uint16(bs[:])).Float32())
default:
panic("unreachable")
}
})
interp.RegisterFunc2("_to_float", func(_ *interp.Interp, c any, nBits int, isLE bool) any {
switch nBits {
case 16, 32, 64:
default:
return fmt.Errorf("unsupported bit size %d, must be 16, 32 or 64", nBits)
}
v, ok := gojqx.Cast[float64](c)
if !ok {
return gojqx.FuncTypeError{Name: "_to_float", V: v}
}
var b [8]byte
bs := b[:][0 : nBits/8]
switch nBits {
case 64:
binary.BigEndian.PutUint64(bs, math.Float64bits(v))
case 32:
binary.BigEndian.PutUint32(bs, math.Float32bits(float32(v)))
case 16:
binary.BigEndian.PutUint16(bs, uint16(mathx.NewFloat16(float32(v))))
default:
panic("unreachable")
}
if isLE {
decode.ReverseBytes(bs[:])
}
br, err := interp.NewBinaryFromBitReader(bitio.NewBitReader(bs, -1), 8, 0)
if err != nil {
return err
}
return br
})
interp.RegisterFS(bitsFS)
}

12
format/bits/bits.jq Normal file
View File

@ -0,0 +1,12 @@
def from_f16be: _from_float(16; false);
def from_f32be: _from_float(32; false);
def from_f64be: _from_float(64; false);
def from_f16le: _from_float(16; true);
def from_f32le: _from_float(32; true);
def from_f64le: _from_float(64; true);
def to_f16le: _to_float(16; true);
def to_f32le: _to_float(32; true);
def to_f64le: _to_float(64; true);
def to_f16be: _to_float(16; false);
def to_f32be: _to_float(32; false);
def to_f64be: _to_float(64; false);

View File

@ -262,6 +262,29 @@ func jpegDecode(d *decode.D) any {
}
})
})
case DHT:
lH := int64(d.FieldU16("lh"))
d.FramedFn(lH*8-16, func(d *decode.D) {
d.FieldArray("hs", func(d *decode.D) {
for d.NotEnd() {
d.FieldStruct("h", func(d *decode.D) {
d.FieldU4("tc")
d.FieldU4("th")
hK := uint64(0)
hV := uint64(0)
d.FieldArrayLoop("l", func() bool { return hK < 16 }, func(d *decode.D) {
hV += d.FieldU8("l")
hK++
})
hK = 0
d.FieldArrayLoop("v", func() bool { return hK < hV }, func(d *decode.D) {
d.FieldU8("v")
hK++
})
})
}
})
})
case RST0, RST1, RST2, RST3, RST4, RST5, RST6, RST7:
inECD = true
case TEM:

View File

@ -109,15 +109,57 @@ $ fq -d jpeg dv 4x4.jpg
| | | [4]{}: marker 0x66-0x7c (22)
0x60| ff | . | prefix: raw bits (valid) 0x66-0x67 (1)
0x60| c4 | . | code: "dht" (196) (Define Huffman table(s)) 0x67-0x68 (1)
0x60| 00 14 | .. | length: 20 0x68-0x6a (2)
0x60| 00 01 00 00 00 00| ......| data: raw bits 0x6a-0x7c (18)
0x70|00 00 00 00 00 00 00 00 00 00 00 08 |............ |
0x60| 00 14 | .. | lh: 20 0x68-0x6a (2)
| | | hs[0:1]: 0x6a-0x7c (18)
| | | [0]{}: h 0x6a-0x7c (18)
0x60| 00 | . | tc: 0 0x6a-0x6a.4 (0.4)
0x60| 00 | . | th: 0 0x6a.4-0x6b (0.4)
| | | l[0:16]: 0x6b-0x7b (16)
0x60| 01 | . | [0]: 1 l 0x6b-0x6c (1)
0x60| 00 | . | [1]: 0 l 0x6c-0x6d (1)
0x60| 00 | . | [2]: 0 l 0x6d-0x6e (1)
0x60| 00 | . | [3]: 0 l 0x6e-0x6f (1)
0x60| 00| .| [4]: 0 l 0x6f-0x70 (1)
0x70|00 |. | [5]: 0 l 0x70-0x71 (1)
0x70| 00 | . | [6]: 0 l 0x71-0x72 (1)
0x70| 00 | . | [7]: 0 l 0x72-0x73 (1)
0x70| 00 | . | [8]: 0 l 0x73-0x74 (1)
0x70| 00 | . | [9]: 0 l 0x74-0x75 (1)
0x70| 00 | . | [10]: 0 l 0x75-0x76 (1)
0x70| 00 | . | [11]: 0 l 0x76-0x77 (1)
0x70| 00 | . | [12]: 0 l 0x77-0x78 (1)
0x70| 00 | . | [13]: 0 l 0x78-0x79 (1)
0x70| 00 | . | [14]: 0 l 0x79-0x7a (1)
0x70| 00 | . | [15]: 0 l 0x7a-0x7b (1)
| | | v[0:1]: 0x7b-0x7c (1)
0x70| 08 | . | [0]: 8 v 0x7b-0x7c (1)
| | | [5]{}: marker 0x7c-0x92 (22)
0x70| ff | . | prefix: raw bits (valid) 0x7c-0x7d (1)
0x70| c4 | . | code: "dht" (196) (Define Huffman table(s)) 0x7d-0x7e (1)
0x70| 00 14| ..| length: 20 0x7e-0x80 (2)
0x80|10 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................| data: raw bits 0x80-0x92 (18)
0x90|00 00 |.. |
0x70| 00 14| ..| lh: 20 0x7e-0x80 (2)
| | | hs[0:1]: 0x80-0x92 (18)
| | | [0]{}: h 0x80-0x92 (18)
0x80|10 |. | tc: 1 0x80-0x80.4 (0.4)
0x80|10 |. | th: 0 0x80.4-0x81 (0.4)
| | | l[0:16]: 0x81-0x91 (16)
0x80| 01 | . | [0]: 1 l 0x81-0x82 (1)
0x80| 00 | . | [1]: 0 l 0x82-0x83 (1)
0x80| 00 | . | [2]: 0 l 0x83-0x84 (1)
0x80| 00 | . | [3]: 0 l 0x84-0x85 (1)
0x80| 00 | . | [4]: 0 l 0x85-0x86 (1)
0x80| 00 | . | [5]: 0 l 0x86-0x87 (1)
0x80| 00 | . | [6]: 0 l 0x87-0x88 (1)
0x80| 00 | . | [7]: 0 l 0x88-0x89 (1)
0x80| 00 | . | [8]: 0 l 0x89-0x8a (1)
0x80| 00 | . | [9]: 0 l 0x8a-0x8b (1)
0x80| 00 | . | [10]: 0 l 0x8b-0x8c (1)
0x80| 00 | . | [11]: 0 l 0x8c-0x8d (1)
0x80| 00 | . | [12]: 0 l 0x8d-0x8e (1)
0x80| 00 | . | [13]: 0 l 0x8e-0x8f (1)
0x80| 00| .| [14]: 0 l 0x8f-0x90 (1)
0x90|00 |. | [15]: 0 l 0x90-0x91 (1)
| | | v[0:1]: 0x91-0x92 (1)
0x90| 00 | . | [0]: 0 v 0x91-0x92 (1)
| | | [6]{}: marker 0x92-0x9c (10)
0x90| ff | . | prefix: raw bits (valid) 0x92-0x93 (1)
0x90| da | . | code: "sos" (218) (Start of scan) 0x93-0x94 (1)

12
go.mod
View File

@ -19,7 +19,7 @@ require (
// bump: gomod-ergochat-readline /github\.com\/ergochat\/readline v(.*)/ https://github.com/ergochat/readline.git|*
// bump: gomod-ergochat-readline command go get -d github.com/ergochat/readline@v$LATEST && go mod tidy
// bump: gomod-ergochat-readline link "Release notes" https://github.com/ergochat/readline/releases/tag/v$LATEST
github.com/ergochat/readline v0.1.0
github.com/ergochat/readline v0.1.1
// bump: gomod-golang-snappy /github\.com\/golang\/snappy v(.*)/ https://github.com/golang/snappy.git|^0
// bump: gomod-golang-snappy command go get -d github.com/golang/snappy@v$LATEST && go mod tidy
@ -48,7 +48,7 @@ require (
// bump: gomod-golang-x-crypto /golang\.org\/x\/crypto v(.*)/ https://github.com/golang/crypto.git|^0
// bump: gomod-golang-x-crypto command go get -d golang.org/x/crypto@v$LATEST && go mod tidy
// bump: gomod-golang-x-crypto link "Tags" https://github.com/golang/crypto/tags
golang.org/x/crypto v0.22.0
golang.org/x/crypto v0.23.0
// has no tags
// go get -d golang.org/x/exp@master && go mod tidy
@ -57,17 +57,17 @@ require (
// bump: gomod-golang-x-net /golang\.org\/x\/net v(.*)/ https://github.com/golang/net.git|^0
// bump: gomod-golang-x-net command go get -d golang.org/x/net@v$LATEST && go mod tidy
// bump: gomod-golang-x-net link "Tags" https://github.com/golang/net/tags
golang.org/x/net v0.24.0
golang.org/x/net v0.25.0
// bump: gomod-golang-x-term /golang\.org\/x\/term v(.*)/ https://github.com/golang/term.git|^0
// bump: gomod-golang-x-term command go get -d golang.org/x/term@v$LATEST && go mod tidy
// bump: gomod-golang-x-term link "Tags" https://github.com/golang/term/tags
golang.org/x/term v0.19.0
golang.org/x/term v0.20.0
// bump: gomod-golang/text /golang\.org\/x\/text v(.*)/ https://github.com/golang/text.git|^0
// bump: gomod-golang/text command go get -d golang.org/x/text@v$LATEST && go mod tidy
// bump: gomod-golang/text link "Source diff $CURRENT..$LATEST" https://github.com/golang/text/compare/v$CURRENT..v$LATEST
golang.org/x/text v0.14.0
golang.org/x/text v0.15.0
// bump: gomod-gopkg.in/yaml.v3 /gopkg\.in\/yaml\.v3 v(.*)/ https://github.com/go-yaml/yaml.git|^3
// bump: gomod-gopkg.in/yaml.v3 command go get -d gopkg.in/yaml.v3@v$LATEST && go mod tidy
@ -79,6 +79,6 @@ require (
github.com/itchyny/timefmt-go v0.1.5 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/sys v0.20.0 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
)

24
go.sum
View File

@ -2,8 +2,8 @@ github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/creasty/defaults v1.7.0 h1:eNdqZvc5B509z18lD8yc212CAqJNvfT1Jq6L8WowdBA=
github.com/creasty/defaults v1.7.0/go.mod h1:iGzKe6pbEHnpMPtfDXZEr0NVxWnPTjb1bbDy08fPzYM=
github.com/ergochat/readline v0.1.0 h1:KEIiAnyH9qGZB4K8oq5mgDcExlEKwmZDcyyocgJiABc=
github.com/ergochat/readline v0.1.0/go.mod h1:o3ux9QLHLm77bq7hDB21UTm6HlV2++IPDMfIfKDuOgY=
github.com/ergochat/readline v0.1.1 h1:C8Uuo3ybB23GWOt0uxmHbGzKM9owmtXary6Clrj84s0=
github.com/ergochat/readline v0.1.1/go.mod h1:o3ux9QLHLm77bq7hDB21UTm6HlV2++IPDMfIfKDuOgY=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/gomarkdown/markdown v0.0.0-20240328165702-4d01890c35c0 h1:4gjrh/PN2MuWCCElk8/I4OCKRKWCCo2zEct3VKCbibU=
@ -25,18 +25,18 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/wader/gojq v0.12.1-0.20240401131232-6c6bc364201a h1:P881Oecjt9FEXrwkGJ6UObJksxejJaF/fKq1ZfXpiVE=
github.com/wader/gojq v0.12.1-0.20240401131232-6c6bc364201a/go.mod h1:qVrzkUdnBtJvM4twyRQ6xdziPSnSp35dLm4s/DN2iP4=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw=
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

View File

@ -54,9 +54,6 @@ Same as recurse without argument.
}
};
def help($_): error("help must be alone or last in pipeline. ex: help(length) or ... | help");
def help: help(null);
def _help_format_enrich($arg0; $f; $include_basic):
( if $include_basic then
.examples +=
@ -76,6 +73,9 @@ def _help_format_enrich($arg0; $f; $include_basic):
end
);
# trailing help gets rewritten to _help_slurp, these are here to catch other variants
def help($_): error("help must be alone or last in pipeline. ex: help(length) or ... | help");
def help: help(null);
def _help($arg0; $topic):
( $topic
| if . == "usage" then
@ -236,7 +236,7 @@ def _help($arg0; $topic):
| ($args | length) as $argc
| if $args == null then
# help
( "Type expression to evaluate"
( "Type jq expression to evaluate"
, "help(...) Help for topic. Ex: help(mp4), help(\"mp4\")"
, "\\t Completion"
, "Up/Down History"

View File

@ -1,6 +1,6 @@
$ fq -ni
null> help
Type expression to evaluate
Type jq expression to evaluate
help(...) Help for topic. Ex: help(mp4), help("mp4")
\t Completion
Up/Down History