Commit Graph

86 Commits

Author SHA1 Message Date
Mike Farah
ef6fb92e7f Log printing follow no-colors flag #2082 2024-06-29 15:26:10 +10:00
Mike Farah
e092329bf3 String interpolation! #1149 2024-03-05 14:10:12 +11:00
Mike Farah
447bf28cd8 Introduced 'format' to encapsulate encoding and decoding formats together 2024-02-24 16:37:13 +11:00
Mike Farah
571caa696a Refactoring Output types 2024-02-24 14:58:11 +11:00
Mike Farah
359c4a11b2 Merge branch 'feat/completions' of github.com:scop/yq into scop-feat/completions 2024-02-24 13:48:42 +11:00
Mike Farah
b24b484efc Added --properties-array-brackets flag for properties encoder #1933 2024-02-20 11:39:56 +11:00
Ryan Drew
2865022cf8
Add --properties-separator option (#1951)
This commit adds the --properties-separator option, which lets users
specify the separator used between keys and values in the properties
output format. This is done by adjusting the value of
github.com/magiconair/properties#Properties.WriteSeparator at encode
time.

Some refactoring of the properties encoder unit tests was done to make
it easier to write unit tests that include different separator values.

Fixes: #1864

Signed-off-by: Ryan Drew <ryan.drew@isovalent.com>
2024-02-20 10:57:44 +11:00
Mike Farah
9a8151d316 Added csv separator flag #1950 2024-02-17 19:11:41 +11:00
Mike Farah
3c3f1180d9 Cleaning up log message formats 2024-02-16 09:44:22 +11:00
Mike Farah
9142c93d1b Improved log format 2024-02-16 09:26:31 +11:00
Mike Farah
c32a9ceab8 Added new CSV option to turn off auto-parsing #1947 2024-02-15 13:11:53 +11:00
Ville Skyttä
84890ae34d Add arg and flag completions 2023-12-20 09:36:57 +02:00
Mike Farah
779b26310e Updating references to yq being a YAML processor 2023-11-30 15:32:21 +11:00
Ville Skyttä
eecc106529
Update JSON to YAML example for new JSON input output default (#1875) 2023-11-23 11:54:43 +11:00
Mike Farah
cdb9b56066 Spellig with cspell 2023-09-19 10:43:11 +10:00
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
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
7103b78d38
Draft: Toml (#1439)
* toml wip

* wip

* Fixed auto parsing toml

* Added build flag not to include toml

* Parse toml docs and tests

* minor updates
2023-03-26 10:59:15 +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
ryenus
d30941b575
Detect input format based on file name extension (#1582)
* detect inputFormat from filename

* refactor and extract func InputFormatFromFilename

* detect inputFormat only when file is provided

* add test for automatic input format detection
2023-03-09 10:17:19 +11:00
Mike Farah
43233ce62e Fixed xml decode bug when there is content after a comment 2022-11-25 13:21:19 +11:00
Mike Farah
88ce6ffcbe Hotfix: actually update the default xml attribute prefix #1428 2022-11-13 11:13:34 +11:00
Mike Farah
ececd00fbd Updated default xml naming prefix 2022-11-10 22:22:55 +11:00
Mike Farah
cad809515c Refactoring 2022-11-10 22:07:53 +11:00
Mike Farah
1d35134310 Unwrap scalar now works for JSON encoding when explicitly set #1409 2022-11-10 19:21: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
24bbffd71e xml prefs should be part of API 2022-10-25 14:27:16 +11:00
Mike Farah
6d6b693fb3
Added XML processing instructions and directive support (#1396) 2022-10-24 10:09:42 +11:00
Sandro
7fe937c61e
Map -r to --unwrapScalar to be more a drop in replacement for jq (#1245) 2022-06-23 14:31:31 +10:00
Mike Farah
2bc7dcfcca Handle xml namespaces by default 2022-06-15 17:12:57 -07:00
rndmit
b9309a42a4
XML decoder additions (#1239)
* Add xml-keep-namespace and xml-raw-token features

* Add tests

* Change flags usage strings

* Append docs
2022-06-15 09:40:31 +10:00
Mike Farah
55c5497fab Can specify a split expression file #1194 2022-04-29 11:08:41 +10:00
Mike Farah
5d225b9454 Updating readme 2022-03-29 13:15:27 +11:00
Mike Farah
bbeae229ca Disable strict XML parsing by default #1155 2022-03-28 14:05:10 +11:00
Mike Farah
e08b6803f5 Simplify json > yaml cli example 2022-03-20 10:58:37 +11:00
justin-f-perez
1a964c5055
update cli help (#1146)
- remove duplicate comment
- add common use case (json -> idiomatic yml)
2022-03-20 10:54:24 +11:00
Mike Farah
33a29817d7 Can load expressions from file #1120 2022-03-01 11:50:09 +11:00
Mike Farah
a9c3617b4f
Decoder Properties (#1099)
* Decoder Properties

* Added properties round trip test

* Fixed property decode for github actions

* Refactored XML test to use common functions

* Switched formatScenario parameter order for more readablity
2022-02-10 12:02:53 +11:00
Mike Farah
26356ff4be Added github action fix for parsing xml, updated linter 2022-02-07 11:55:55 +11:00
Mike Farah
2891c6948d Added expression argument to forcibly set expression if required 2022-02-07 09:27:52 +11:00
Mike Farah
535799462f Added eval operator 2022-02-01 14:47:51 +11:00
Mike Farah
a6fc7aa881 Updating docs 2022-01-28 10:06:25 +11:00
Mike Farah
4ec533bc1b No longer have to specify eval! 2022-01-27 12:07:41 +11:00
Mike Farah
fc276ff450 Smarter behaviour when piping data in with one argument 2022-01-27 10:18:46 +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
c48b1612df Updating cli docs 2021-12-21 17:07:32 +11:00
Mike Farah
6763ae6e7b Added xml acceptance tests 2021-12-21 17:05:33 +11:00
Mike Farah
2ee9c65bc2 Added global xml prefs for simplicity 2021-12-21 16:52:54 +11:00
Mike Farah
df32baedf1
Added XML decoder (#1044) 2021-12-21 15:02:07 +11:00
Mike Farah
0b2688c0f1 Split printer 2021-10-30 10:04:41 +11:00