1
1
mirror of https://github.com/wader/fq.git synced 2024-10-06 00:17:58 +03:00
Commit Graph

92 Commits

Author SHA1 Message Date
Mattias Wadman
8d69f1fb23 interp: Change default bits_format=string
I think this is more intuitive but might in some case cause very large JSON output
but maybe that less common or expected. In does cases i think you either want to
use some other bits_format (md5, truncate, etc) or you delete/transform the jq value
before turn it into JSON.

Strings in gojq are binary safe so you can use to hold raw bytes. But note that
convert the binary into JSON is lossy, same as the JSON standard.

Add bits_format option documentation.
2022-12-01 17:49:34 +01:00
Mattias Wadman
c93301fc70 raw,bits,bytes: Replace raw format with bits and bytes format that decode to a binary
raw format was a hack to skip decoding to be able to get a binary using tobyte etc.
Now you can do fq -d bytes ... instead of fq -d raw 'tobytes | ...'
2022-11-20 19:51:12 +01:00
Mattias Wadman
00ee10a1a1 interp: Make to{actual,sym} behave similar to tovalue
Before if you did toactual it behaved differently and even gave error for
a scalar that only had actual value set. Now both to{actal,sym} works
similar to tovalue but will force if actual or sym value should be used.
2022-09-25 17:53:12 +02:00
Mattias Wadman
095e1161b7 xml: Switch from "-" to "@" as attribute prefix and make it an option
Seems to be more common.
2022-08-25 17:15:23 +02:00
Mattias Wadman
701c67c136 jsonl: Add decoder, also tojsonl encoder 2022-08-15 19:43:59 +02:00
Mattias Wadman
f4e0137244 xml,html: Always include attrs and children in array mode
Was hard to use when you dont know what indexes things will have. They are sill optioal for toxml
2022-08-04 11:44:59 +02:00
Mattias Wadman
10cc551871 doc: Improve and cleanup text formats
Hopefully will get time to revamp how docs work
2022-07-24 11:55:50 +02:00
Mattias Wadman
cae288e6be format,intepr: Refactor json, yaml, etc into formats also move out related functions
json, yaml, toml, xml, html, csv are now normal formats and most of them also particiate
in probing (not html and csv).

Also fixes a bunch of bugs in to/fromxml, to/fromjq etc.
2022-07-23 21:48:45 +02:00
Mattias Wadman
7aff654a43 doc: Clarify decode, slurp and spew args 2022-07-21 20:56:19 +02:00
Mattias Wadman
b03887229c doc: Use singular jq value to refer to jq value 2022-07-10 10:44:56 +02:00
Mattias Wadman
d4fe00d65c
Merge pull request #299 from wader/interp-add-group
interp: Add group/0
2022-06-30 12:31:37 +02:00
Mattias Wadman
b10061196f doc: Typos and add note about Try* functions 2022-06-30 12:23:59 +02:00
Sergei Kuzmin
02f00be9a6
Update usage.md 2022-06-26 04:56:56 -07:00
Mattias Wadman
a3c33fc1f4 interp: Add group/0
Also add tests for count, count_by, delta and delta_by
2022-06-21 15:18:12 +02:00
Mattias Wadman
3b717c3ba4 interp: Add to/from<encoding> for some common serialzations, encodings and hashes
Add toxml/fromxml for XML encoding, mighe be lossy on ordering
fromxml has {seq:bool} to add #seq attributes to improve ordering
toxml has {indent:number} to choose space indent depth

Add tojson, same as in jq but also has {indent:number} options

Add toyaml/fromyaml for YAML

Add totoml/fromtoml for TOML

Add tojq/fromjq for jq-flavored JSON (optional quotes for keys, comments and trailing commas support)

Add tocsv/fromcsv for CSV
formcvs takes {comma:string, comment:string} for custom separtor and comment character

Rename/split hex into tohex/fromhex
Rename/split base64 into tobase64/frombase64
tobase64/frombase64 takes {encoding:string} option for base64 flavour (std, url, rawstd, rawurl)

Add to/from<format> urlpath, urlquery, url, xmlentities, base64, hex

Add to<hash> md4, md5, sha1, sha256, sha512, sha3_224, sha3_256, sha3_384, sha3_512

Add to/from<encoding> iso8859-1, utf8, utf16, utf16le, utf16be
2022-05-28 16:31:20 +02:00
Mattias Wadman
dff7e7dadb interp: Cleanup binary regexp overloading and add explode
Add explode for binary that explode into an array of the binary unit tobits
Remove scan_toend as it feels a bit weird and one can use tobytes | .[match(...):] instead
Some general cleanup also
2022-03-09 20:17:12 +01:00
Mattias Wadman
0a043f9096 repl,interp: Refactor repl and slurp
Now repl, slurp and help implemented using same query rewrite.
Include filename context in error if possible.
Add spew function that does opposite of slurp.
Start of help infra, not done or documented yet.
Show error pointer on parse error.
Rename internal eval to _eval and make eval be wrapper that
does rewrite and has various eror handling etc.
Nicer repl, slupr and help errors.
2022-03-01 18:31:00 +01:00
Mattias Wadman
48a19cb82c interp: Add paste function to allow pasting text into REPL etc
Also refactor readline and eval args into option struct and partinally start
addressing some side effects during completion.
2022-02-11 17:59:06 +01:00
Mattias Wadman
36307857de doc: Cleanup and add more decode value and binary documentation 2022-02-09 21:08:01 +01:00
Mattias Wadman
06245d1295 binary,decode,doc: Rename buffer to binary and add some documentation
Rename buffer to binary. Still some work left what to call buffer/binary in decode code.
Document decode value and binary type
Fix proper unit padding for tobytes and add still undocumenated extra padding argument.
Add some additional binary tests
2022-02-08 22:20:28 +01:00
Mattias Wadman
366f6b185c interp: Support force decode as -o force=true 2022-02-05 17:24:42 +01:00
Mattias Wadman
6b51b0676f doc: More display alias leftover fixes 2022-01-29 13:22:10 +01:00
Mattias Wadman
f0ce7179b2 doc: Document display and some more jq hints
Also fixed some verbose -> dv leftovers
2022-01-29 13:10:25 +01:00
Mattias Wadman
b66e3287f2
Merge pull request #112 from wader/interp-cleanup-d-alises
interp: Cleanup display aliases, now: d, da, dd, dv, ddv
2022-01-29 12:28:46 +01:00
Mattias Wadman
7bc2521938 doc,interp: Add some example usages to cli help 2022-01-29 12:21:51 +01:00
Mattias Wadman
fc0aacb654 interp: Cleanup display aliases, now: d, da, dd, dv, ddv
Think it makes sense to have them all start with d.
Also f is often used as function argument name.
2022-01-28 18:25:38 +01:00
Mattias Wadman
c52a1a2364 doc: Use f($a; $b) instead of jq f/2 notation
Also some general polish
2022-01-27 09:55:45 +01:00
Mattias Wadman
e792598c69 interp: Add grep_by/1 to recursively match using a filter
Refactor other grep functions to use it
2022-01-24 18:26:25 +01:00
Mattias Wadman
8e9700d0bd doc: Improve readme a bit and add torepr example 2022-01-15 19:26:58 +01:00
Mattias Wadman
149cb3f45a interp: Add torepr/0 that converts decode value into what it reptresents
Ex: fq -d msgpack torepr file.msgpack
Willoutput the JSON representation of the msgpack

Make per format *_torepr functions internal
2022-01-12 17:33:58 +01:00
Mattias Wadman
b3a09805a4 interp: Document bit opts funcs and add some error tests 2022-01-09 10:43:07 +01:00
Mattias Wadman
e365f22084 interp: Cleanup stdio usage and functions 2022-01-05 21:41:11 +01:00
Mattias Wadman
a41f0d4b5f windows: Correct @builtin include path join
Failed because go embed paths always uses /
Switch to always use forward slash paths internally

Related to #21
2022-01-04 22:10:53 +01:00
Mattias Wadman
d440c4fa11
Merge pull request #45 from wader/doc-improve2
doc: Some more dev infomration
2021-12-31 17:18:24 +01:00
Mattias Wadman
6db7218093 doc: Some more dev infomration 2021-12-31 17:13:16 +01:00
Mathieu Aubin
c90e3e1d0c
typpp 2021-12-30 08:56:50 -05:00
Mattias Wadman
63485efda8 doc: Add hopes, pronounce and some more examples 2021-12-28 23:13:23 +01:00
Mattias Wadman
eb4a6fdbd6 doc: Remove empty comment 2021-12-22 19:34:06 +01:00
Mattias Wadman
6491d08fb0 doc: Add more common usages 2021-12-22 19:33:21 +01:00
Mattias Wadman
916cb30618 doc: Improve usage examples as bit 2021-12-20 17:21:07 +01:00
Mattias Wadman
d02c7c42ff doc: Add some more usage examples 2021-12-20 15:15:43 +01:00
Mattias Wadman
e1e8a236e6 doc: Add color/unicode section and move config section 2021-12-19 11:51:24 +01:00
Mattias Wadman
f7c7801bbe interp: Rework buffer regex support
Now all regexp functions should work similar to string version for buffers.
Added scan_toend that works as scan but outputs buffer from match to end of buffer,
useful when trying to decode a format and you dont know or care to limit.
2021-12-17 16:23:44 +01:00
Mattias Wadman
9aec91a675 interp: match: Fix issue with regexp meta characters when matching using a buffer 2021-12-04 17:24:43 +01:00
Mattias Wadman
07b421011f interp: add topath/0 and make todescription return null if there is none
Move out more code from funcs.jq
2021-11-19 11:44:23 +01:00
Mattias Wadman
07c7daaf92 doc: Some rewording 2021-11-19 00:23:04 +01:00
Mattias Wadman
f9f866000e interp,decode: Add force option to ignore asserts 2021-11-16 13:03:56 +01:00
Mattias Wadman
3fafee8559 interp: Clearer help for -d 2021-11-16 08:43:29 +01:00
Mattias Wadman
1b32b42f93 decode: Major decode API refactor
Generate more code
More generic and comfortable API
Improve and Update format decoder to new API
Add some more format tests
2021-11-15 21:12:07 +01:00
Mattias Wadman
6a15625587 interp,decode: Refactor out Scalar from Value and merge Array/Struct into Compound
Also add tosym, toactual
2021-11-05 17:29:22 +01:00