Commit Graph

43 Commits

Author SHA1 Message Date
Kim Alvefur
d302d75c77
Implement basic Lua output support (#1745)
* Implement basic Lua output support

Ref #1700

Basic but working serialization to Lua tables.

* Escape larger set of characters in Lua output

Started with a minimum of replacements, this should be more complete,
tho not all substitutions are strictly required in Lua.

* Print simple keys unquoted in Lua output

String keys that satisfy the requirements for variable names can be used
as keys without quotes in tables.

* Quote Lua keywords in table keys

Keywords are not valid as unquoted keys, thus must be quoted

* Make output of unquoted Lua table keys optional

Generally safer and simpler to not do it.

* Hook up settings for Lua output

* Allow special characters in Lua prefix and suffix

--lua-suffix='});^M' didn't work, so taking this approach instead

* Panic on unhandled YAML Kind in Lua encoder

* Handle YAML case varied booleans in Lua encoder

* Handle special-case numbers in Lua encoder

* Reject unhandled scalar Tags in Lua encoder

* Add note about how Lua nil is unsuitable as table key

Could add some context tracking in the future to allow rejecting nil in
a table key context.

* Return error instead of panic in Lua encoder

* Add initial test for Lua encoder

Boilerplate mostly copied from toml_test.go

* Additional Lua output tests

* Generate Lua encoder documentation

Mostly just for the boilerplate

* Convert octal for Lua output

Lua doesn't have the 0oNNN syntax for octal integers, only decimal and
hexadecimal, hence those can be passed trough as is while octal needs
special treatment.

* Implement indentation in in Lua output

* Respect string Style in Lua encoder

Lua has 'single', "double" and [[ long ]] strings.

* Expand Lua examples

* Output line comments in Lua output

* Implement Lua globals output mode
2023-08-11 12:56:49 +10:00
Giorgio Gallo
80b42b81fd
Implement shell output format (#1645)
* fix typo in a comment

* implement shell output format

* fix a typo

* add two test cases, have source uses ascii only

* add integration tests and documentation

* add fixes after code revieew
2023-05-04 11:06:56 +10:00
Mike Farah
eba075294a Added scalar output for TOML (#1617) 2023-04-03 15:40:06 +10:00
Valentin Lab
5fd2890d1b
Add `--nul-output|-0` flag to separate element with NUL character (#1550)
This is to ensure solid parsing of complex data (with any binary
content except NUL chars) by separating the `yq` root collection
member's output with NUL char. As a safe-guard, an error will be cast
if trying to use NUL character with content that contains itself NUL
characters inside.
2023-03-29 09:51:55 +11:00
Mike Farah
08a6cb65fe
Auto output format (#1599)
* Use file extension to auto detect output format!

* Use file extension to auto detect output format!

* formatting
2023-03-15 13:22:58 +11:00
Mike Farah
d21bb920d6 Added shell string encoder (@sh) #1526 2023-02-02 12:23:08 +11:00
Mike Farah
6d7d76a3f1 Adds @uri/@urid #1529 2023-01-23 11:37:18 +11:00
Mike Farah
880397d549
Refactored decoder responsibilities (#1402)
- improved comment handling
- yaml decoder now responsible for leading content work around
2022-10-28 14:16:46 +11:00
Mike Farah
6bce23d9c2 Improved handling of trailing document comments 2022-05-25 10:54:03 +10:00
Mike Farah
d9bca65626 Added base64 support 2022-02-23 09:26:35 +11:00
Mike Farah
26356ff4be Added github action fix for parsing xml, updated linter 2022-02-07 11:55:55 +11:00
Mike Farah
ec8ef312ef
Added XML encoding/decoding (#1067)
* Added XML encoding/decoding

* Minor fixes

* Improve yq doc

* Lint
2022-01-15 11:57:59 +11:00
Mike Farah
2ee9c65bc2 Added global xml prefs for simplicity 2021-12-21 16:52:54 +11:00
Mike Farah
6bcbd873a6 wip 2021-12-21 16:19:27 +11:00
Mike Farah
d0419ceedf Added csv, tsv output formats 2021-12-02 20:06:51 +11:00
Mike Farah
11b6261e8b remove leading content indicator 2021-11-14 10:59:50 +11:00
Mike Farah
d912d7d178 wip 2021-11-14 10:59:50 +11:00
Mike Farah
0b2688c0f1 Split printer 2021-10-30 10:04:41 +11:00
Mike Farah
d18aa3e9e0 Added shorthand output formats 2021-08-20 15:46:33 +10:00
Mike Farah
8c1a96d121 Properties encoder wip 2021-07-25 18:08:33 +10:00
Mike Farah
3b91ad5764 Handle leading comment with no new-line 2021-07-20 11:01:56 +10:00
Mike Farah
8508d3309b More efficient front matter processor 2021-07-20 10:38:42 +10:00
Mike Farah
4e628327c4 Better way of processing leading content 2021-07-20 10:19:55 +10:00
Mike Farah
bbebebe30c Fixed for most cases, except strip comments 2021-07-20 09:18:40 +10:00
Mike Farah
519cf1dcd7 wip 2021-07-19 19:58:47 +10:00
Mike Farah
3a6f73e836 wip 2021-07-19 19:52:51 +10:00
Mike Farah
555ad0762c Added front-matter handler 2021-07-18 12:28:46 +10:00
Mike Farah
f6e2ab5cef Remember comments in empty files 2021-07-16 22:08:22 +10:00
Mike Farah
d74bb8e28d Adding magic to detect leading seperators 2021-07-15 11:34:49 +10:00
Mike Farah
3722367fbb Dont print doc separators for JSON (https://github.com/mikefarah/yq/issues/735) 2021-03-19 12:40:56 +11:00
Mike Farah
c6efd5519b Pass context through operators
Allows more sophisticated functionality
2021-02-11 10:58:40 +11:00
Mike Farah
e86f83fb69 Renaming pathtree to expression 2021-02-11 10:58:40 +11:00
Mike Farah
7d5b6b5442 Removed global vars 2021-02-11 10:58:40 +11:00
Mike Farah
286590b01e fixing exposed functions and interfaces 2021-02-11 10:58:40 +11:00
Mike Farah
09a9e1e7f0 handle multiple document streams 2020-12-15 14:33:50 +11:00
Mike Farah
c9229439f7 added exit status 2020-11-30 16:35:21 +11:00
Mike Farah
8de10e550d wip - write in place 2020-11-29 20:25:47 +11:00
Mike Farah
a57944d123 Fixed printer 2020-11-16 12:09:57 +11:00
Mike Farah
af39fc737d Fixed linting 2020-11-13 14:07:11 +11:00
Mike Farah
708ff02e8d Fixed collect object for multi doc 2020-11-13 13:19:54 +11:00
Mike Farah
2edf64182b refining 2020-11-06 14:37:01 +11:00
Mike Farah
b290a65602 document index 2020-11-06 12:11:38 +11:00
Mike Farah
b1f139c965 refactored 2020-11-04 10:48:43 +11:00