1
1
mirror of https://github.com/wader/fq.git synced 2024-11-23 00:57:15 +03:00
Commit Graph

55 Commits

Author SHA1 Message Date
Mattias Wadman
dff3cc1199 interp: dump: Fix column truncate issue with unicode bars 2022-05-11 00:37:52 +02:00
Mattias Wadman
f4480c6fe5 decode,interp: Support for format specific options
interp: Refactor format help and also include options
interp: Add -o name=@path to load file content as value (not documented yet, might change)
interp,decode: Expose decode out value as _out (might change)
interp: Refactor foramts.jq into format_{decode,func,include}.jq
interp: Refactor torepr into _format_func for generic format function overloading
interp: Refactor -o options parsing to be more generic and collect unknowns options to be used as format options
decode of decode alises
func for format overloaded functions
include for format specific jq functions (also _help, torepr etc)
flac_frame: Add bits_per_sample option
mp3: Add max_unique_header_config and max_sync_seek options
mp4: Add decode_samples and allow_truncate options
avc_au: Has length_size option
hevc_au: Has length_size option
aac_frame: Has object_typee option
doc: Rewrite format doc generation, less hack more jq
2022-05-01 17:08:30 +02:00
Mattias Wadman
607202bb67 interp: Don't truncate last display column
Wrapping lines might be annoying but not seeing things even worse i think.
Hopefully once column config is in jq it could be an option.
2022-04-19 18:19:42 +02:00
Mattias Wadman
dabad85080 interp: Proper display column truncate
Also speed up by using less string allocs
2022-04-16 18:48:21 +02:00
Mattias Wadman
518f6af4a8 gojq: Rebase fq fork
Upstream changes:
Many performance improvements
Error message improvments
Lots of refactoring

Most of the JQValue interface changes in gojq fork had to be reworked but
resultet in a much nicer and cleaner changeset.

fq changes:
Assignment to JQValue (like a decode value) now shallowly converts the value into
a jq value before assigning. Was a bit hacky as it was and this makes JQValue
behave more like real jq values. This also fixes some advanced indexing issues.

Actual custom path updates will be something for the future.
2022-04-11 19:23:15 +02:00
Mattias Wadman
d376520f11 interp: Remove to*range pad argument and fix stdout padding issue
Padding could end up double.
Remove to*range($pad) as it probably just confusing to be able
to pad an existing range, what to show in hexdump etc? zero bits
that do not actuall exist at that range?

Add tests and binary stdout support to tests
2022-03-17 20:15:35 +01:00
Mattias Wadman
41551de331 interp,repl: Improved eval and output interrupt
repl now rewrites query to do implicit display inside the sub eval.
This makes it possible to interrupt eval and output in a better and faster way.

Make JSON encoder fail early on errors.

Add more interrupt tests.
2022-03-11 16:22:30 +01: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
c6a90cfc1d doc,asn1_ber: Add more documentation 2022-02-16 20:02:23 +01:00
Mattias Wadman
9e4f264193 dev: Add .jq-lsp.jq to add additional builtins for jq-lsp
Fixes missing function errors for fq builtins
Add includes to fix some other missing function errors

Add COMPLETION_TIMEOUT env to increase comepletion timeout during test using -race
2022-02-16 19:52:42 +01:00
Mattias Wadman
9dc59e5d39 interp: Move _is_decode_value to jq
Make _extype work like type
2022-02-15 22:20:32 +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
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
7c5215347d bitio,decode: Refactor bitio usage and make buffer slicing more correct
Remove bitio.Buffer layer. bitio.Buffer was a kitchen sink layer with helpers
now it's just a buffer and most functions have been moved to decode instead.

bitio package now only have primitive types and functions simialar to standard
library io and bytes packages.

Make nearly eveything internally use bitio.Bit* interfaces so that slicing work
correctly this will also make it possible to start experimenting with more
complicated silcing helpers, ex things like:
breplace(.header.bitrate; 123) to get a new buffer with bitrate changed.
2022-02-04 21:41:53 +01:00
Mattias Wadman
ca68e6a1e4 interp: Add Platform() method to OS interface
Felt bad that main should have to know about it
2022-01-29 11:31:36 +01:00
Mattias Wadman
898dfec1d1 lint: Fix typeassert and case exhaustive warnings 2022-01-25 17:23:41 +01:00
Mattias Wadman
548a065388 decode,interp: Finish up nil value support
Update msgpack, bson and cbor to use it.
2022-01-17 10:49:46 +01:00
Mattias Wadman
edad481878 num,mathextra: Rename num package to mathextra
Think it makes more sense
2022-01-15 19:00:42 +01:00
Mattias Wadman
1383b411ae decode,interp: Add arbitrary large integer support (BigInt)
Was already handled in fq in various places as gojq uses them

Update msgpack to support negative integers that can't represented as int64
Rename read try* number functions to make them more explicit
2022-01-15 19:00:42 +01:00
Mattias Wadman
0b0f28e966 cbor: Add decoder
Does not decode sematic tag types
Also fixes broken float16 support

Fixes #71
2022-01-12 17:56:03 +01:00
Mattias Wadman
9770b0046b repl: Make prompt for array and iter more jqish
Really need to refactor script.go some day into a proper parser
2022-01-10 20:02:43 +01:00
Mattias Wadman
be0ef80c8d interp,fq: Make bit operators normal functions
Uses same rule as jq math functions, 1 arg uses input, more than one all passed as args.
So "bnot 1" -> "1 | bnot", "1 bsl 1" -> "bsl(1; 1)"

Don't think it's worth changing the jq syntax for this and also it could make fq
scripts no compatiblr with other jq tools. Non-10 base number literals are still allowed
but should probably not be used in scripts, only in repl and with cli.
2022-01-09 01:06:36 +01:00
Mattias Wadman
bf9e13c85a windows: Unbreak tests
Normalize OS specific errors paths to make difftests work

Related to #21
2022-01-04 22:11:25 +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
9f2dddc6e1 interp,gojqextra: Make buffers values even more lazy and error early on non-scalar calls 2021-11-29 14:51:00 +01:00
Mattias Wadman
fdb811ec54 gojqextra,decode: Add generic lazy JQValue 2021-11-22 01:23:59 +01:00
Mattias Wadman
1047d909ac doc: Document io packages a bit 2021-11-21 21:55:53 +01:00
Mattias Wadman
aab32cf2db gojqextra,interp: Add lazy string to speed usage of decode value buffer where string is not used 2021-11-21 21:27:44 +01:00
Mattias Wadman
74b57501b5 shquote: Remove unnecessary sb.Reset() 2021-11-20 10:46:36 +01:00
Mattias Wadman
b66ed32614 decode,interp: Make fuzzing work again and cleanup fatal/error code 2021-11-16 17:11:26 +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
Mattias Wadman
6cacc9b398 interp: Move *CtxWriter to ioextra, some comments cleanup 2021-11-05 17:28:29 +01:00
Mattias Wadman
13fae09172 interp: Don't print context cancel 2021-11-01 13:01:05 +01:00
Mattias Wadman
1e1ad14cc2 difftest: Sync code 2021-10-30 01:26:00 +02:00
Mattias Wadman
95ec5e1077 Cleanup and rename s/BufferView/BufferRange 2021-10-21 00:48:30 +02:00
Mattias Wadman
4af5739712 interp: Rework string/buffer for decode values 2021-10-20 01:31:59 +02:00
Mattias Wadman
5052bae18e decode,interp: Refactor to allow decode/fillgap a range 2021-10-19 14:38:11 +02:00
Mattias Wadman
7f36f703dd Add to/bytes/bits[range] 2021-10-17 14:43:37 +02:00
Mattias Wadman
e86b45bd1a Add *grep/1/2 and find/1/2 2021-10-13 01:27:04 +02:00
Mattias Wadman
b17a7155b5 difftest: Remove accidental log 2021-10-10 21:19:40 +02:00
Mattias Wadman
f0233bb811 test: Refactor out diff testing into own package 2021-10-10 17:20:49 +02:00
Mattias Wadman
691688022f fqtest: Refactor our script part to own package
Hopefully can be reused for docs generation
2021-10-06 18:49:03 +02:00
Mattias Wadman
15e9f6f0af ansi: Correct background reset code 2021-09-30 22:37:45 +02:00
Mattias Wadman
9035278e81 gojqextra: Move errors to own file 2021-09-28 01:45:32 +02:00
Mattias Wadman
3ff0c9b5e0 lint: Enable errcheck adnd revive 2021-09-27 11:01:14 +02:00
Mattias Wadman
110c86b959 interp: Fix broken dynamic width/height
Refactor options to fixed/dynamic and just use stack
Added support for env in fqtest readlines
2021-09-22 18:18:57 +02:00
Mattias Wadman
976e992c31 interp: Move progress logic to jq 2021-09-20 17:47:40 +02:00
Mattias Wadman
31d7611f55 fqtest: Add env support and isterminal/width/height support 2021-09-19 02:17:31 +02:00
Mattias Wadman
b33f2cd678 cli: Make profile build optional and move it to cli 2021-09-12 13:08:53 +02:00