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

Merge pull request #936 from wader/update-docs

doc: Cleanup and improve texts a bit
This commit is contained in:
Mattias Wadman 2024-04-30 14:25:36 +02:00 committed by GitHub
commit 496849daa5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 20 deletions

View File

@ -2,25 +2,23 @@
Tool, language and decoders for working with binary data. 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) ![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). For details see [usage.md](doc/usage.md).
### Background ### 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. 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.
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!
### Goals ### Goals
- Make binaries accessible, queryable and sliceable. - Make binaries more accessible, queryable and sliceable.
- Nested formats and bit-oriented decoding. - Nested formats and bit-oriented decoding.
- Quick and comfortable CLI tool. - Quick and comfortable CLI tool.
- Bits and bytes transformations. - 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. 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 ```sh
# build and install latest release # build and install latest release
go install github.com/wader/fq@latest go install github.com/wader/fq@latest
@ -267,10 +265,6 @@ go build -o fq .
make test fq make test fq
``` ```
## TODO and ideas
See [TODO.md](doc/TODO.md)
## Development and adding a new decoder ## Development and adding a new decoder
See [dev.md](doc/dev.md) 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. - [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). - [Data Format Description Language (DFDL)](https://en.wikipedia.org/wiki/Data_Format_Description_Language).
## TODO and ideas
See [TODO.md](doc/TODO.md)
## License ## License
`fq` is distributed under the terms of the MIT License. `fq` is distributed under the terms of the MIT License.

View File

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

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): def _help_format_enrich($arg0; $f; $include_basic):
( if $include_basic then ( if $include_basic then
.examples += .examples +=
@ -76,6 +73,9 @@ def _help_format_enrich($arg0; $f; $include_basic):
end 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): def _help($arg0; $topic):
( $topic ( $topic
| if . == "usage" then | if . == "usage" then
@ -236,7 +236,7 @@ def _help($arg0; $topic):
| ($args | length) as $argc | ($args | length) as $argc
| if $args == null then | if $args == null then
# help # help
( "Type expression to evaluate" ( "Type jq expression to evaluate"
, "help(...) Help for topic. Ex: help(mp4), help(\"mp4\")" , "help(...) Help for topic. Ex: help(mp4), help(\"mp4\")"
, "\\t Completion" , "\\t Completion"
, "Up/Down History" , "Up/Down History"

View File

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