mirror of
https://github.com/wader/fq.git
synced 2024-11-23 09:56:07 +03:00
108 lines
2.4 KiB
Plaintext
108 lines
2.4 KiB
Plaintext
$ fq -ni
|
|
null> abc | slurp
|
|
error: expr: slurp requires one string argument. ex: ... | slurp("name")
|
|
null> slurp | 1
|
|
error: slurp must be last in pipeline. ex: ... | slurp("name")
|
|
null> abc | slurp("a")
|
|
error: expr: function not defined: abc/0
|
|
null> "a"+1 | slurp("a")
|
|
error: cannot add: string ("a") and number (1)
|
|
null> 123 | slurp("a")
|
|
null> 123, "bb" | slurp("bb")
|
|
null> 123, 456, error("err"), "bb" | slurp("err")
|
|
error: err
|
|
null> spew
|
|
{
|
|
"a": [
|
|
123
|
|
],
|
|
"bb": [
|
|
123,
|
|
"bb"
|
|
],
|
|
"err": [
|
|
123,
|
|
456
|
|
]
|
|
}
|
|
null> spew("bb")
|
|
123
|
|
"bb"
|
|
null> $a
|
|
[
|
|
123
|
|
]
|
|
null> "aa" | slurp("a")
|
|
null> spew
|
|
{
|
|
"a": [
|
|
"aa"
|
|
],
|
|
"bb": [
|
|
123,
|
|
"bb"
|
|
],
|
|
"err": [
|
|
123,
|
|
456
|
|
]
|
|
}
|
|
null> $a
|
|
[
|
|
"aa"
|
|
]
|
|
null> . | repl
|
|
> null> $bb
|
|
[
|
|
123,
|
|
"bb"
|
|
]
|
|
> null> ^D
|
|
null> 123 | slurp("a b")
|
|
error: expr: invalid slurp name "a b", must be a valid identifier. ex: ... | slurp("name")
|
|
null> 123 | slurp(null)
|
|
error: expr: invalid slurp name "null", must be a valid identifier. ex: ... | slurp("name")
|
|
null> ^D
|
|
$ fq -i
|
|
null> 1,2,3 | repl
|
|
> number, ...[0:3][]> ., .*2 | slurp("b")
|
|
> number, ...[0:3][]> if . == 2 then error("err") end | slurp("c")
|
|
error: err
|
|
> number, ...[0:3][]> ^D
|
|
null> spew
|
|
{
|
|
"b": [
|
|
1,
|
|
2,
|
|
2,
|
|
4,
|
|
3,
|
|
6
|
|
],
|
|
"c": [
|
|
1,
|
|
3
|
|
]
|
|
}
|
|
null> ^D
|
|
$ fq -d mp3 -i . test.mp3
|
|
mp3> .frames[0] | slurp("f")
|
|
mp3> $f[]
|
|
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.frames[0]{}: frame (mp3_frame)
|
|
0x20| ff fb 40| ..@| header{}:
|
|
0x30|c0 |. |
|
|
0x30| 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00| ...............| side_info{}:
|
|
0x40|00 00 |.. |
|
|
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
|
|
0x40| 49 6e 66 6f 00 00 00 0f 00 00 00 02 00 00| Info..........| tag{}: (mp3_frame_xing)
|
|
0x50|02 57 00 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6|.W..............|
|
|
* |until 0xdd.7 (156) | |
|
|
0xd0| 00 00| ..| audio_data: raw bits
|
|
0xe0|00 00 00 |... |
|
|
| | | crc_calculated: "827a" (raw bits)
|
|
mp3> ^D
|
|
$ fq -n slurp
|
|
exitcode: 3
|
|
stderr:
|
|
error: arg: slurp can only be used from interactive repl
|