Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Cleanup and improve texts a bit #936

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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

**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.
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions doc/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pkg/interp/help.jq
Original file line number Diff line number Diff line change
Expand Up @@ -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 +=
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pkg/interp/testdata/help.fqtest
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading