Commit Graph

791 Commits

Author SHA1 Message Date
Mike Farah
cda69bff5e Adding recipes 2023-09-01 12:17:54 +10:00
Mike Farah
e5564c18fe Another xml example 2023-09-01 11:52:58 +10:00
Mike Farah
55c0d485ba Fixed string, null concact consistency #1712 2023-08-30 09:46:45 +10:00
Mike Farah
71f95ab87b Fixed .a!= parsing issue #1711 2023-08-30 09:40:57 +10:00
Mike Farah
d18a5e3adc Fixed new linting issue CWE-118 2023-08-28 17:39:46 +10:00
Mike Farah
44c7f3aec3 Preparing release notes 2023-08-11 13:52:50 +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
Mike Farah
fcc04823ca Added docs on base64 only working with utf8 content 2023-05-23 15:38:08 +10:00
Mike Farah
5950329e2c Added docs on yes/no being strings in yaml spec 1.2 2023-05-23 15:35:39 +10:00
Mike Farah
4d50b001d1 Added test for null array json example 2023-05-04 14:48:57 +10:00
Arthur Fritz Santiago
d14eaa9b49
fix: runtime error: invalid memory address or nil pointer dereference (#1649) 2023-05-04 14:43:48 +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
385921a3e2 Fixed passing of readonly context in pipe 2023-04-11 12:04:04 +10:00
Mike Farah
eba075294a Added scalar output for TOML (#1617) 2023-04-03 15:40:06 +10:00
Mike Farah
a389bb64b8 Fixed bug when splatting empty array #1613 2023-03-31 16:24:23 +11:00
Mike Farah
496035c75a toml docs 2023-03-31 10:24:12 +11: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
8d516ce535 Handle scalars in csv, xml files 2023-03-27 13:54:24 +11:00
Mike Farah
1b0a62d08d Handle scalars in property files 2023-03-27 13:51:08 +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
95aafdd8d5 Fixed modulo docs 2023-03-18 14:53:36 +11:00
Mike Farah
fdce8fce13 Added docs 2023-03-18 14:51:31 +11:00
Mike Farah
dccba10997 added another base64 test 2023-03-18 14:33:48 +11:00
TJ Miller
69d3e3f3f8
Add support for decoding base64 strings without padding (#1604) 2023-03-18 14:30:35 +11:00
Mike Farah
ac8ffa287e doc gen 2023-03-16 13:41:10 +11:00
Abel Sen
fa6fac1a76
Minor typos (#1595)
* Remove extra backtick

* Reword explanation of update

* Reword explanation of relative update

* Change "remaple" to "remain"

* Change "clovver" to "clobber"

* Reword explanation of update for comment operators

* Reword explanation of relative update for comment operators

* Change "array" to "expression"

* Change "the golangs" to "Golang's"

* Change "golangs" to "Golang's"

* Change "can durations" to "can add durations"

* Change "array scalars" to "arrays"

* Change "beit" to "be it"

* Fix typo in `eval` tip

* Fix typo in header for `has` operation

* Add space before pipe in `line` operator example

* Fix typos in explanation of deep array merges

* Change "is now used" to "is now used."

* Change "object," to "object."

* Changes "indexes" to "indices"

* Remove extraneous copied text from `..` article

* Reword explanation of `...` operator

* Change "your are" to "you are"

* Add link to `string` operator docs in `select` article

* Change "is a" to "parameter specifies" in `string` operators article

* Change "new line" to "newline"

* Change "golang regex" to "Golang's regex"

* Change "golang" to "Golang"

* Add period

* Remove comma in `subtract` article

* Remove duplicate number subtraction example

* Remove comma in `traverse` operator article

* Clarify use of brackets when `read`ing with special characters
2023-03-16 13:39:36 +11:00
TJ Miller
a466821e8f
Added divide and modulo operators (#1593)
* Added divide operator (#49)

* Tidy up divide operator logic

* Added modulo operator

* Fix divide test typo

* Add divide by zero test

* Handle int modulo by 0 and add tests

* Tidy up divide/modulo operator node creation

* Fix linter errors
2023-03-15 20:14:23 +11:00
Mike Farah
360a47fddc Fixed npe in log #1596 2023-03-15 13:57:47 +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
Robert Brennan
9539877ff6
Add filter operation (#1588)
* add filter operation

* add tests

* add tests

* revert debug

* simplify filter

* fix tests

* remove logs
2023-03-09 10:30:47 +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
2195df9e7a Fixed xml encoding of ProcInst #1563, improved XML comment handling 2023-03-02 10:57:54 +11:00
Mike Farah
3f1f66a8ee Fixed merged anchor reference problem #1482 2023-03-01 13:45:35 +11:00
Anders Björklund
cf8cfbd865
Allow build without json and xml support (#1556)
* Refactor ordered_map into separate files

Separate json and xml, from the regular yaml.

Makes it possible to compile, without those...

* Refactor encoder and decoder creation

Use more consistent parameters vs globals

Return errors instead of calling panic()

* Allow build without json and xml support
2023-03-01 13:19:06 +11:00
Mike Farah
62d167c141
Variable loop - Fixes #1566 (#1577)
* Variable loop wip

* Variable loop wip

* Variable loop wip

* Variable loop wip

* Fixed variable operator to work like jq
2023-02-28 16:40:38 +11:00
Mike Farah
d17fd9424e Added shuffle command #1503 2023-02-11 05:08:20 +11:00
Mike Farah
a1698b740a Added ability to sort by multiple fields #1541 2023-02-11 04:46:39 +11:00
Vít Zikmund
93b7c999be
Use a lazy-quoting @sh encoder (#1548)
* Use a lazy-quoting @sh encoder

* Add internal quoting style switch to @sh

* Add test for stray empty quotes in @sh
2023-02-09 18:15:07 +11:00
Mike Farah
88a6b20ba5 Fixed date comparison with string date #1537 2023-02-02 13:30:48 +11:00
Mike Farah
915ab69922 Added to_unix operator 2023-02-02 12:56:16 +11:00
Mike Farah
f9f340b6bf Github pipeline not in AU tz :D 2023-02-02 12:47:59 +11:00
Mike Farah
75920481b1 Added from_unix operator #1535 2023-02-02 12:42:36 +11:00
Mike Farah
d21bb920d6 Added shell string encoder (@sh) #1526 2023-02-02 12:23:08 +11:00
Mike Farah
3b1bcac5b3 review feed back on URI 2023-01-25 11:18:48 +11:00
Mike Farah
6d7d76a3f1 Adds @uri/@urid #1529 2023-01-23 11:37:18 +11:00
Mike Farah
473be23153 Log info message when unable to chown file #1521 2023-01-15 11:36:52 +11:00
Mike Farah
3b84c03131 Fixed bug in splice operator #1511 2023-01-13 13:45:19 +11:00
Mike Farah
d7da0cca3c Fixed value operator bug #1515 2023-01-12 15:11:45 +11:00
Mike Farah
fcda053d73 Updating tests from lexer version bump 2023-01-12 14:26:58 +11:00
Mike Farah
00c2be541d Added prepend array example 2023-01-11 12:19:46 +11:00
Mike Farah
9af55d555b Fixed handling of merging null #1501 2023-01-10 13:48:57 +11:00
Mike Farah
18cdea3f88
Build constraint not working for non linux (#1481)
* Build constraint not working for non linux

* Go Build Constraint: Fix Non-Linux Filename (#1494)

Correct the filename pkg/yqlib/chown_not_linux.go to escape the
default OS detection in filename format `*_GOOS[_test].go`.

Add an extra word after `linux` to resolve the issue.
pkg/yqlib/chown_not_linux_os.go

Signed-off-by: Bhargav Ravuri <vaguecoder0to.n@gmail.com>

Signed-off-by: Bhargav Ravuri <vaguecoder0to.n@gmail.com>

Signed-off-by: Bhargav Ravuri <vaguecoder0to.n@gmail.com>
Co-authored-by: Bhargav Ravuri <saibhargavravuri@gmail.com>
2023-01-03 15:52:01 +11:00
Mike Farah
48d00f807e Fixed xml comment in array of scalars #1465 2022-12-17 10:27:54 +11:00
Mike Farah
83c5e1bc83 Include blank new lines in leading header preprocessing #1462 2022-12-08 13:33:06 +11:00
Mike Farah
f9a8ba91e4 Preparing release 2022-11-28 08:34:58 +11:00
Mike Farah
1617e5de19 XML Decoder: Comment parsing tweak 2022-11-27 19:14:41 +11:00
Mike Farah
77998d1bb3 XML Decoder: Fixed processing comments in empty XML #1446 2022-11-27 17:58:37 +11:00
Mike Farah
68f47c02c8 XML Decoder: Checking for invalid content outside of a root node #1448 2022-11-27 17:46:50 +11:00
Mike Farah
02be2b2918 Fixed issue where content surrounding tags are lost #1447 2022-11-27 17:29:27 +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
51043770bf Fixed log level, deleted commented code 2022-11-25 12:09:45 +11:00
Mike Farah
4478bd14c9 Fixed loading yaml with header issue #1445 2022-11-25 12:05:56 +11:00
Mike Farah
fd35530f35 Set tags on maps,arrays when decoding json #1422 2022-11-15 11:42:31 +11:00
Mike Farah
cb609a1886 Fixed bad line entry for #1422 2022-11-15 11:35:31 +11:00
Mike Farah
762f46ed54 include yaml directives #1424 2022-11-14 17:22:13 +11:00
Mike Farah
e02bb71948 Fixed parsing of newline character in string expression #1430 2022-11-14 16:40:59 +11:00
Mike Farah
ffc20f7e2c Length compares to null instead of 0 issue #1427 2022-11-14 16:14:08 +11:00
Mike Farah
3e795d020d Updating docs 2022-11-13 11:16:01 +11:00
Mike Farah
88ce6ffcbe Hotfix: actually update the default xml attribute prefix #1428 2022-11-13 11:13:34 +11:00
Mike Farah
817287ec90 Check merge alias is a map #1425 2022-11-11 14:53:45 +11:00
Mike Farah
c5994a8b28 Simplified json error check 2022-11-11 09:50:22 +11:00
Mike Farah
3435fee1f9 Fixed handling of json decoding error #1423 2022-11-10 22:33:43 +11:00
Mike Farah
ececd00fbd Updated default xml naming prefix 2022-11-10 22:22:55 +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
04847502bf Can use expressions in slice #1419 2022-11-10 18:03:18 +11:00
Mike Farah
af7e36bd47 Improved set path example 2022-11-10 10:28:29 +11:00
Mike Farah
fdad478684 Improved set path example 2022-11-10 10:22:08 +11:00
Mike Farah
22f376bbfd Added set path example 2022-11-10 10:17:08 +11:00
Mike Farah
688fe55bb9 Added test for err fix 2022-11-09 21:46:00 +11:00
Jingyu
91b3fb2af3
fix lib.go handled error (#1418) 2022-11-09 21:36:53 +11:00
Mike Farah
bd5e5dc965 Array to map operator for #1415 2022-11-08 13:40:00 +11:00
Mike Farah
cf02b90624 Fixed sorting by date #1412 2022-11-04 12:21:12 +11:00
Mike Farah
a0be871a9d Only maps can be encoded to XML #1408 2022-11-02 21:41:39 +11:00
Mike Farah
5af062a86f Added subset example 2022-11-01 09:29:05 +11:00
Mike Farah
ed551bf339 Added extra parseSnippet test 2022-11-01 09:15:59 +11:00
Mike Farah
c887042a1b Fixing null csv bug #1404 2022-10-30 22:02:08 +11:00
Mike Farah
6d6cd43255 docs 2022-10-29 18:22:30 +11:00
Mike Farah
d99614f55a
Slice array (#1403) 2022-10-29 18:15:21 +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
c62e18f9b2 Fixed load operator bug 2022-10-25 13:30:38 +11:00
Mike Farah
c1640fb10d Removing old version notice 2022-10-25 12:47:13 +11:00
Mike Farah
6bf3defe85 Fixing updates in square brackets #1342 2022-10-24 17:55:19 +11:00
Mike Farah
6d6b693fb3
Added XML processing instructions and directive support (#1396) 2022-10-24 10:09:42 +11:00
Mike Farah
6db7acbf69 Added custom sort map example 2022-10-17 15:03:47 +11:00
Mike Farah
d16ee386d2 Fixed broken link 2022-10-14 14:24:57 +11:00
Mike Farah
c640888133 Fixed bug - can now delete documents #1377 2022-10-11 11:48:18 +11:00
Mike Farah
33ec66cfdd Fixed handling of UTF8 encoded CSVs #1373 2022-10-08 13:12:50 +11:00
Mike Farah
1b8d399de4 Detect and fail on missing closing brackets #1366 2022-10-08 12:44:54 +11:00
Mike Farah
b5b81abb90 Added DELPATHS operator 2022-10-05 20:09:53 +11:00
Mike Farah
da3f3b93b4 Added SETPATH operator 2022-10-05 14:12:08 +11:00
Mike Farah
7f4c8e1c78 Added comment operator examples 2022-09-30 11:30:31 +10:00
Mike Farah
60f30f8a48 Added comment operator examples 2022-09-30 11:26:36 +10:00
Mike Farah
2362451fda Added comment operator examples 2022-09-30 11:22:58 +10:00
Mike Farah
55a7fdfd8a Added is_key operator 2022-09-30 10:27:35 +10:00
Mike Farah
3dd5f0c80c Added another comment test 2022-09-30 10:15:41 +10:00
Mike Farah
be304a1102 Added another comment test 2022-09-30 09:46:07 +10:00
Mike Farah
b20477210f Added missing validation for adding sequences to maps #1341 2022-09-16 10:04:48 +10:00
Mike Farah
51b64e6cf3 Fixing relative merge bug #1333 2022-09-09 12:28:38 +10:00
Mike Farah
a64eea3b1a Fixed bug in alternative op, dont evaluate RHS if LHS is truthy 2022-09-09 11:05:12 +10:00
Mike Farah
bf6b4d3941 Fixed footer comment issue #1321 2022-08-30 11:24:26 +10:00
Mike Farah
b4ca184108 Added new "c" flag to clobber custom tags when needed 2022-08-29 15:38:21 +10:00
Mike Farah
b1a40a9fb7 Bumped go compiler; bumped quality tools 2022-08-29 14:13:15 +10:00
Mike Farah
a696dceea4 Added string trim operator 2022-08-08 13:35:57 +10:00
Mike Farah
2c9b5be408 Fixed json decode to maintain key order 2022-08-01 16:26:43 +10:00
Mike Farah
a91a8ccc66 Improving docs 2022-08-01 14:12:35 +10:00
Mike Farah
c8815f5ab9
Csv decoder (#1290)
* WIP: adding CSV decoder

* Adding CSV decoder

* Added CSV roundtrip

* Fixing from review
2022-08-01 10:28:34 +10:00
Jih-Wei, Liang
3c222d8707
Added StringEvaluator for evaluating string input #1266 (#1278) 2022-08-01 08:50:56 +10:00
Mike Farah
8c3a8c085e Fixes xml decode missing tags #1284 2022-07-29 10:26:50 +10:00
Mike Farah
b9a1ef89fe
Added NDJSON decoder (#1281) 2022-07-27 12:26:22 +10:00
Mike Farah
03ba38eaff
Using new lexer by alecthomas! (#1270) 2022-07-13 14:45:28 +10:00
Mike Farah
f393cf37c2 Dont clobber anchor when adding nodes - fixes #1269 2022-07-13 11:12:15 +10:00
Mike Farah
86c2b03630 Added error operator for custom validation #1259 2022-06-25 12:46:24 +10:00
Daniel Carbone
98b411f82e
adding support for --wrapScalar=false in properties encoder (#1241)
* adding support for --wrapScalar=false in properties encoder

* altering encoder and decoder tests somewhat

* adding .idea

* Revert "altering encoder and decoder tests somewhat"

This reverts commit e3655130e2.

* adding test scenario for encoding with wrapped scalars
2022-06-25 12:22:03 +10:00
Mike Farah
06d2aaad80 Adding acceptance test for #1257, fixed panic 2022-06-25 12:15:28 +10:00
Hayama
9b47a29864
hotfix: fix panic multiply assign (#1257) 2022-06-25 12:08:52 +10:00
Mike Farah
be05df03b5 Fixing usage of quoted numeric keys #1247 2022-06-23 19:22:11 +10:00
Mike Farah
dfd396b480 When split expression includes an extension, dont add .yml automatically 2022-06-23 14:31:09 +10:00
Mike Farah
60c037f57e Can add string to scalars in any order #1234 2022-06-15 17:09:17 -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
8d3be1a23c Length (and some other operators) should not include head/foot comments #1231 2022-05-31 16:28:53 +10:00
Mike Farah
439bcaad25 Added multiple object example from PR #1226 2022-05-27 11:22:10 +10:00
Mike Farah
294da55012 Fixed base64/xml decode an empty string #1209 2022-05-27 11:18:38 +10:00
Mike Farah
8d32e6a82c Fixed base64 decode an empty string #1209 2022-05-27 10:56:43 +10:00
Mike Farah
1e27e39927 Fixing typos (prefer UK english) 2022-05-25 11:02:18 +10:00
Mike Farah
5126f3dfee Fixed doc 2022-05-25 10:54:56 +10:00
Mike Farah
6bce23d9c2 Improved handling of trailing document comments 2022-05-25 10:54:03 +10:00
Christoph Stäbler
dee592eb3b
Fix typo (#1222) 2022-05-24 18:18:27 +10:00
Mike Farah
451d8643ee Updating merge docs 2022-05-24 16:16:58 +10:00
Mike Farah
fbe49c3700 Added colors to json output #1208 2022-05-22 21:19:59 +10:00
Mike Farah
72cdde78f6 Fixing issues found by codeql 2022-05-06 13:46:14 +10:00
Mike Farah
689c535a29 Updated unique docs 2022-04-29 12:16:57 +10:00
Mike Farah
67c79b7cb1 Fixes append map bug when key matches value in existing map #1200 2022-04-28 14:45:45 +10:00
Mike Farah
26529fae94 Nicer error message when trying to use merge anchor tags other than maps #1184 2022-04-27 14:46:52 +10:00
Mike Farah
90261a2fdd Added type as an alias for tag #1195 2022-04-27 09:11:43 +10:00
Mike Farah
b11075ec98 now assumes yaml idiomatic formatting when adding to empty maps/arrays 2022-04-15 08:27:22 +10:00
Mike Farah
ea66a73f43 Fixed sort dropping head comment #1181 2022-04-14 12:19:15 +10:00
Mike Farah
6f9f80cc48 Fixes with operation bug #1174 2022-04-14 12:03:18 +10:00
Mike Farah
523b8335d8 Fixing string docs 2022-04-01 13:21:55 +11:00
Mike Farah
0956eefb1a Fixed help links 2022-03-29 11:08:50 +11:00