mirror of
https://github.com/wader/fq.git
synced 2024-12-23 13:22:58 +03:00
doc: Fix typos and old examples
This commit is contained in:
parent
88eade9ab9
commit
08142063b3
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -3,12 +3,14 @@
|
|||||||
"AACSSR",
|
"AACSSR",
|
||||||
"acsp",
|
"acsp",
|
||||||
"addrbase",
|
"addrbase",
|
||||||
|
"annexb",
|
||||||
"APETAGEX",
|
"APETAGEX",
|
||||||
"APEV",
|
"APEV",
|
||||||
"APIC",
|
"APIC",
|
||||||
"Arity",
|
"Arity",
|
||||||
"BCDU",
|
"BCDU",
|
||||||
"bgrep",
|
"bgrep",
|
||||||
|
"bxor",
|
||||||
"bzip",
|
"bzip",
|
||||||
"CCIT",
|
"CCIT",
|
||||||
"chzyer",
|
"chzyer",
|
||||||
@ -122,6 +124,7 @@
|
|||||||
"toarray",
|
"toarray",
|
||||||
"toboolean",
|
"toboolean",
|
||||||
"tobytes",
|
"tobytes",
|
||||||
|
"tobytesrange",
|
||||||
"toimage",
|
"toimage",
|
||||||
"tojson",
|
"tojson",
|
||||||
"tojvalue",
|
"tojvalue",
|
||||||
|
12
README.md
12
README.md
@ -34,8 +34,10 @@ To install directly from git repository do:
|
|||||||
```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
|
||||||
|
|
||||||
# or build and install latest master
|
# or build and install latest master
|
||||||
go install github.com/wader/fq@master
|
go install github.com/wader/fq@master
|
||||||
|
|
||||||
# copy binary to $PATH if needed
|
# copy binary to $PATH if needed
|
||||||
cp "$(go env GOPATH)/bin/fq" /usr/local/bin
|
cp "$(go env GOPATH)/bin/fq" /usr/local/bin
|
||||||
```
|
```
|
||||||
@ -49,15 +51,7 @@ cp fq /usr/local/bin
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Basic usage is:
|
Basic usage is `fq . file`. For more details see [usage.md](doc/usage.md).
|
||||||
|
|
||||||
[fq -h | grep Usage: | sed 's/\(.*\)/<pre>\1<\/pre>/']: sh-start
|
|
||||||
|
|
||||||
<pre>Usage: fq [OPTIONS] [--] [EXPR] [FILE...]</pre>
|
|
||||||
|
|
||||||
[#]: sh-end
|
|
||||||
|
|
||||||
For more usage details see [usage.md](doc/usage.md).
|
|
||||||
|
|
||||||
## Supported formats
|
## Supported formats
|
||||||
|
|
||||||
|
24
doc/usage.md
24
doc/usage.md
@ -16,29 +16,33 @@ with auto completion and nested REPL support:
|
|||||||
|
|
||||||
```
|
```
|
||||||
# start REPL with null input
|
# start REPL with null input
|
||||||
fq -i
|
$ fq -i
|
||||||
|
null>
|
||||||
# same as
|
# same as
|
||||||
fq -ni
|
$ fq -ni
|
||||||
|
null>
|
||||||
# start REPL with one file as input
|
# start REPL with one file as input
|
||||||
fq -i . file.mp3
|
$ fq -i . file.mp3
|
||||||
|
mp3>
|
||||||
```
|
```
|
||||||
|
|
||||||
In the REPL you will see a prompt indicating current input and you can type jq expression to evaluate.
|
In the REPL you will see a prompt indicating current input and you can type jq expression to evaluate.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
$ fq -i . file.mp3
|
||||||
# basic arithmetics
|
# basic arithmetics
|
||||||
mp3> 1+1
|
mp3> 1+1
|
||||||
2
|
2
|
||||||
# "." is the identity function, returns current input, the mp3 file.
|
# "." is the identity function which just returns current input, the mp3 file.
|
||||||
mp3> .
|
mp3> .
|
||||||
# access the first frame in the mp3 file
|
# access the first frame in the mp3 file
|
||||||
mp3> .frames[0]
|
mp3> .frames[0]
|
||||||
# start a new nested REPl with first frame as input
|
# start a new nested REPL with first frame as input
|
||||||
mp3> .frames[0] | repl
|
mp3> .frames[0] | repl
|
||||||
# prompt shows "path" to current input and that it's an mp3_frame.
|
# prompt shows "path" to current input and that it's an mp3_frame.
|
||||||
# do Ctrl-D to exit REPL
|
# Ctrl-D to exit REPL
|
||||||
> .frames[0] mp3_frame> ^D
|
> .frames[0] mp3_frame> ^D
|
||||||
# do Ctrl-D to exit to shell
|
# Ctrl-D to exit to shell
|
||||||
mp3> ^D
|
mp3> ^D
|
||||||
$
|
$
|
||||||
```
|
```
|
||||||
@ -144,7 +148,7 @@ notable is support for arbitrary-precision integers.
|
|||||||
- All `match` and `grep` functions take 1 or 2 arguments. First is a scalar to match, where a string is
|
- All `match` and `grep` functions take 1 or 2 arguments. First is a scalar to match, where a string is
|
||||||
treated as a regexp. A buffer scalar will be matches exact bytes. Second argument are regexp
|
treated as a regexp. A buffer scalar will be matches exact bytes. Second argument are regexp
|
||||||
flags with addition that "b" will treat each byte in the input buffer as a code point, this
|
flags with addition that "b" will treat each byte in the input buffer as a code point, this
|
||||||
makes it possible to match exact bytes, ex: `match("\u00ff"; b")` will match the byte `0xff` and not
|
makes it possible to match exact bytes, ex: `match("\u00ff"; "b")` will match the byte `0xff` and not
|
||||||
the UTF-8 encoded codepoint for 255.
|
the UTF-8 encoded codepoint for 255.
|
||||||
- `match/1`, `match/2` overloaded to support buffers. Match in buffer and output match buffers
|
- `match/1`, `match/2` overloaded to support buffers. Match in buffer and output match buffers
|
||||||
- `grep/1`, `grep/2` recursively match value and buffer
|
- `grep/1`, `grep/2` recursively match value and buffer
|
||||||
@ -226,9 +230,9 @@ you know the format of some unknown value. Then you can decode manually.
|
|||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
# try decode a `mp3_frame` that failed to decode
|
# try decode a `mp3_frame` that failed to decode
|
||||||
$ fq file.mp3 .unknown0 mp3_frame
|
$ fq -d mp3 '.unknown0 | mp3_frame' file.mp3
|
||||||
# skip first 10 bytes then decode as `mp3_frame`
|
# skip first 10 bytes then decode as `mp3_frame`
|
||||||
$ fq file.mp3 .unknown0._bytes[10:] mp3_frame
|
$ fq -d raw 'tobytes[10:] | mp3_frame' file.mp3
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
### Use `.` as input and in a positional argument
|
### Use `.` as input and in a positional argument
|
||||||
|
Loading…
Reference in New Issue
Block a user