yq/pkg/yqlib
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
..
doc Implement basic Lua output support (#1745) 2023-08-11 12:56:49 +10:00
all_at_once_evaluator_test.go handled EvaluateNodes panic (#1140) 2022-03-15 13:28:52 +11:00
all_at_once_evaluator.go Refactored decoder responsibilities (#1402) 2022-10-28 14:16:46 +11:00
candidate_node.go Added new "c" flag to clobber custom tags when needed 2022-08-29 15:38:21 +10:00
chown_linux.go Log info message when unable to chown file #1521 2023-01-15 11:36:52 +11:00
chown_not_linux_os.go Build constraint not working for non linux (#1481) 2023-01-03 15:52:01 +11:00
color_print.go Cleaning up exposed public api 2021-02-11 10:58:40 +11:00
context.go Date Time Ops (#1110) 2022-02-14 15:37:43 +11:00
csv_test.go Handle scalars in csv, xml files 2023-03-27 13:54:24 +11:00
data_tree_navigator.go Draft: Toml (#1439) 2023-03-26 10:59:15 +11:00
decoder_base64.go Add support for decoding base64 strings without padding (#1604) 2023-03-18 14:30:35 +11:00
decoder_csv_object.go Refactored decoder responsibilities (#1402) 2022-10-28 14:16:46 +11:00
decoder_json.go fix: runtime error: invalid memory address or nil pointer dereference (#1649) 2023-05-04 14:43:48 +10:00
decoder_properties.go Draft: Toml (#1439) 2023-03-26 10:59:15 +11:00
decoder_test.go Draft: Toml (#1439) 2023-03-26 10:59:15 +11:00
decoder_toml.go Draft: Toml (#1439) 2023-03-26 10:59:15 +11:00
decoder_uri.go Adds @uri/@urid #1529 2023-01-23 11:37:18 +11:00
decoder_xml.go Fixed xml encoding of ProcInst #1563, improved XML comment handling 2023-03-02 10:57:54 +11:00
decoder_yaml.go Include blank new lines in leading header preprocessing #1462 2022-12-08 13:33:06 +11:00
decoder.go Draft: Toml (#1439) 2023-03-26 10:59:15 +11:00
encoder_base64.go Added base64 support 2022-02-23 09:26:35 +11:00
encoder_csv.go Handle scalars in csv, xml files 2023-03-27 13:54:24 +11:00
encoder_json.go Allow build without json and xml support (#1556) 2023-03-01 13:19:06 +11:00
encoder_lua.go Implement basic Lua output support (#1745) 2023-08-11 12:56:49 +10:00
encoder_properties_test.go Refactored decoder responsibilities (#1402) 2022-10-28 14:16:46 +11:00
encoder_properties.go Handle scalars in property files 2023-03-27 13:51:08 +11:00
encoder_sh.go Use a lazy-quoting @sh encoder (#1548) 2023-02-09 18:15:07 +11:00
encoder_shellvariables_test.go Implement shell output format (#1645) 2023-05-04 11:06:56 +10:00
encoder_shellvariables.go Implement shell output format (#1645) 2023-05-04 11:06:56 +10:00
encoder_test.go Allow build without json and xml support (#1556) 2023-03-01 13:19:06 +11:00
encoder_toml.go Added scalar output for TOML (#1617) 2023-04-03 15:40:06 +10:00
encoder_uri.go review feed back on URI 2023-01-25 11:18:48 +11:00
encoder_xml.go Fixed xml encoding of ProcInst #1563, improved XML comment handling 2023-03-02 10:57:54 +11:00
encoder_yaml.go Minor typos (#1595) 2023-03-16 13:39:36 +11:00
encoder.go Allow build without json and xml support (#1556) 2023-03-01 13:19:06 +11:00
expression_parser_test.go Detect and fail on missing closing brackets #1366 2022-10-08 12:44:54 +11:00
expression_parser.go Detect and fail on missing closing brackets #1366 2022-10-08 12:44:54 +11:00
expression_postfix.go Detect and fail on missing closing brackets #1366 2022-10-08 12:44:54 +11:00
expression_processing_test.go Using new lexer by alecthomas! (#1270) 2022-07-13 14:45:28 +10:00
file_utils.go Bumping to go1.18, bumping dev tools 2022-03-28 14:18:55 +11:00
front_matter_test.go refactor: move from io/ioutil to io and os packages (#1068) 2022-01-21 19:50:53 +11:00
front_matter.go Fixed #1062 2022-01-14 15:22:55 +11:00
json_test.go Added test for null array json example 2023-05-04 14:48:57 +10:00
lexer_participle_test.go Updating tests from lexer version bump 2023-01-12 14:26:58 +11:00
lexer_participle.go Added divide and modulo operators (#1593) 2023-03-15 20:14:23 +11:00
lexer.go Can use expressions in slice #1419 2022-11-10 18:03:18 +11:00
lib_test.go Fixed bad line entry for #1422 2022-11-15 11:35:31 +11:00
lib.go Added divide and modulo operators (#1593) 2023-03-15 20:14:23 +11:00
lua_test.go Implement basic Lua output support (#1745) 2023-08-11 12:56:49 +10:00
lua.go Implement basic Lua output support (#1745) 2023-08-11 12:56:49 +10:00
matchKeyString_test.go Make deepMatch report in linear time 2021-10-14 18:45:25 +11:00
matchKeyString.go Make deepMatch report in linear time 2021-10-14 18:45:25 +11:00
no_json.go Allow build without json and xml support (#1556) 2023-03-01 13:19:06 +11:00
no_toml.go Draft: Toml (#1439) 2023-03-26 10:59:15 +11:00
no_xml.go Allow build without json and xml support (#1556) 2023-03-01 13:19:06 +11:00
operator_add_test.go Variable loop - Fixes #1566 (#1577) 2023-02-28 16:40:38 +11:00
operator_add.go Fixed sorting by date #1412 2022-11-04 12:21:12 +11:00
operator_alternative_test.go Variable loop - Fixes #1566 (#1577) 2023-02-28 16:40:38 +11:00
operator_alternative.go Fixed bug in alternative op, dont evaluate RHS if LHS is truthy 2022-09-09 11:05:12 +10:00
operator_anchors_aliases_test.go Minor typos (#1595) 2023-03-16 13:39:36 +11:00
operator_anchors_aliases.go Check merge alias is a map #1425 2022-11-11 14:53:45 +11:00
operator_array_to_map_test.go Array to map operator for #1415 2022-11-08 13:40:00 +11:00
operator_assign_test.go Minor typos (#1595) 2023-03-16 13:39:36 +11:00
operator_assign.go Added new "c" flag to clobber custom tags when needed 2022-08-29 15:38:21 +10:00
operator_booleans_test.go Added docs on yes/no being strings in yaml spec 1.2 2023-05-23 15:35:39 +10:00
operator_booleans.go Boolean fix (#1148) 2022-03-20 12:55:58 +11:00
operator_collect_object_test.go Fixed passing of readonly context in pipe 2023-04-11 12:04:04 +10:00
operator_collect_object.go enable more linters (#1043) 2021-12-21 09:30:08 +11:00
operator_collect_test.go Fixing updates in square brackets #1342 2022-10-24 17:55:19 +11:00
operator_collect.go Fixed bug when splatting empty array #1613 2023-03-31 16:24:23 +11:00
operator_column_test.go Added line and column operators 2022-02-27 11:56:46 +11:00
operator_column.go Added line and column operators 2022-02-27 11:56:46 +11:00
operator_comments_test.go Include blank new lines in leading header preprocessing #1462 2022-12-08 13:33:06 +11:00
operator_comments.go Refactored decoder responsibilities (#1402) 2022-10-28 14:16:46 +11:00
operator_compare.go Fixed date comparison with string date #1537 2023-02-02 13:30:48 +11:00
operator_contains_test.go Added subset example 2022-11-01 09:29:05 +11:00
operator_contains.go Added contains operator 2021-09-15 15:18:10 +10:00
operator_create_map_test.go Fixed empty array op 2020-11-22 13:50:32 +11:00
operator_create_map.go Bumped go compiler; bumped quality tools 2022-08-29 14:13:15 +10:00
operator_datetime_test.go Added to_unix operator 2023-02-02 12:56:16 +11:00
operator_datetime.go Added to_unix operator 2023-02-02 12:56:16 +11:00
operator_delete_test.go Fixed bug - can now delete documents #1377 2022-10-11 11:48:18 +11:00
operator_delete.go Fixed bug - can now delete documents #1377 2022-10-11 11:48:18 +11:00
operator_divide_test.go Added divide and modulo operators (#1593) 2023-03-15 20:14:23 +11:00
operator_divide.go Added divide and modulo operators (#1593) 2023-03-15 20:14:23 +11:00
operator_document_index_test.go Added snake_case version of camelCase operators (snake case now prefered) 2022-02-11 09:05:17 +11:00
operator_document_index.go Added key operator 2021-11-24 09:57:35 +11:00
operator_encoder_decoder_test.go added another base64 test 2023-03-18 14:33:48 +11:00
operator_encoder_decoder.go Minor typos (#1595) 2023-03-16 13:39:36 +11:00
operator_entries_test.go Minor typos (#1595) 2023-03-16 13:39:36 +11:00
operator_entries.go Fixing usage of quoted numeric keys #1247 2022-06-23 19:22:11 +10:00
operator_env_test.go Length (and some other operators) should not include head/foot comments #1231 2022-05-31 16:28:53 +10:00
operator_env.go Envsubst params (#1147) 2022-03-20 10:56:50 +11:00
operator_equals_test.go Variable loop - Fixes #1566 (#1577) 2023-02-28 16:40:38 +11:00
operator_equals.go Length compares to null instead of 0 issue #1427 2022-11-14 16:14:08 +11:00
operator_error_test.go Added error operator for custom validation #1259 2022-06-25 12:46:24 +10:00
operator_error.go Added error operator for custom validation #1259 2022-06-25 12:46:24 +10:00
operator_eval_test.go Tests can have multiple env variables 2022-02-01 14:58:53 +11:00
operator_eval.go Added github action fix for parsing xml, updated linter 2022-02-07 11:55:55 +11:00
operator_expression.go Array to map operator for #1415 2022-11-08 13:40:00 +11:00
operator_file_test.go Added snake_case version of camelCase operators (snake case now prefered) 2022-02-11 09:05:17 +11:00
operator_file.go Added key operator 2021-11-24 09:57:35 +11:00
operator_filter_test.go Added docs 2023-03-18 14:51:31 +11:00
operator_filter.go Auto output format (#1599) 2023-03-15 13:22:58 +11:00
operator_flatten_test.go Added XML decoder (#1044) 2021-12-21 15:02:07 +11:00
operator_flatten.go Fixed flatten error message 2021-10-26 15:43:43 +11:00
operator_group_by_test.go Added XML decoder (#1044) 2021-12-21 15:02:07 +11:00
operator_group_by.go Added github action fix for parsing xml, updated linter 2022-02-07 11:55:55 +11:00
operator_has_test.go Variable loop - Fixes #1566 (#1577) 2023-02-28 16:40:38 +11:00
operator_has.go Added github action fix for parsing xml, updated linter 2022-02-07 11:55:55 +11:00
operator_keys_test.go Added is_key operator 2022-09-30 10:27:35 +10:00
operator_keys.go Added is_key operator 2022-09-30 10:27:35 +10:00
operator_length_test.go Length (and some other operators) should not include head/foot comments #1231 2022-05-31 16:28:53 +10:00
operator_length.go Added key operator 2021-11-24 09:57:35 +11:00
operator_line_test.go Minor typos (#1595) 2023-03-16 13:39:36 +11:00
operator_line.go Added line and column operators 2022-02-27 11:56:46 +11:00
operator_load_test.go Allow build without json and xml support (#1556) 2023-03-01 13:19:06 +11:00
operator_load.go Allow build without json and xml support (#1556) 2023-03-01 13:19:06 +11:00
operator_map_test.go Added XML decoder (#1044) 2021-12-21 15:02:07 +11:00
operator_map.go Added github action fix for parsing xml, updated linter 2022-02-07 11:55:55 +11:00
operator_modulo_test.go Added divide and modulo operators (#1593) 2023-03-15 20:14:23 +11:00
operator_modulo.go Added divide and modulo operators (#1593) 2023-03-15 20:14:23 +11:00
operator_multiply_test.go Minor typos (#1595) 2023-03-16 13:39:36 +11:00
operator_multiply.go Fixed value operator bug #1515 2023-01-12 15:11:45 +11:00
operator_parent_test.go Added XML decoder (#1044) 2021-12-21 15:02:07 +11:00
operator_parent.go Added more tests 2021-11-24 10:16:48 +11:00
operator_path_test.go Minor typos (#1595) 2023-03-16 13:39:36 +11:00
operator_path.go Fixed value operator bug #1515 2023-01-12 15:11:45 +11:00
operator_pick_test.go Minor typos (#1595) 2023-03-16 13:39:36 +11:00
operator_pick.go Fixes xml decode missing tags #1284 2022-07-29 10:26:50 +10:00
operator_pipe_test.go Fixed passing of readonly context in pipe 2023-04-11 12:04:04 +10:00
operator_pipe.go Fixed passing of readonly context in pipe 2023-04-11 12:04:04 +10:00
operator_recursive_descent_test.go Added XML decoder (#1044) 2021-12-21 15:02:07 +11:00
operator_recursive_descent.go enable more linters (#1043) 2021-12-21 09:30:08 +11:00
operator_reduce_test.go Added XML decoder (#1044) 2021-12-21 15:02:07 +11:00
operator_reduce.go Fixed SEGV error #1096 2022-02-09 11:47:21 +11:00
operator_reverse_test.go Length (and some other operators) should not include head/foot comments #1231 2022-05-31 16:28:53 +10:00
operator_reverse.go Length (and some other operators) should not include head/foot comments #1231 2022-05-31 16:28:53 +10:00
operator_select_test.go Minor typos (#1595) 2023-03-16 13:39:36 +11:00
operator_select.go Added github action fix for parsing xml, updated linter 2022-02-07 11:55:55 +11:00
operator_self.go Pass context through operators 2021-02-11 10:58:40 +11:00
operator_shuffle_test.go Added shuffle command #1503 2023-02-11 05:08:20 +11:00
operator_shuffle.go Added shuffle command #1503 2023-02-11 05:08:20 +11:00
operator_slice_test.go Fixed bug in splice operator #1511 2023-01-13 13:45:19 +11:00
operator_slice.go Fixed bug in splice operator #1511 2023-01-13 13:45:19 +11:00
operator_sort_keys_test.go Added XML decoder (#1044) 2021-12-21 15:02:07 +11:00
operator_sort_keys.go Added github action fix for parsing xml, updated linter 2022-02-07 11:55:55 +11:00
operator_sort_test.go Added ability to sort by multiple fields #1541 2023-02-11 04:46:39 +11:00
operator_sort.go Added ability to sort by multiple fields #1541 2023-02-11 04:46:39 +11:00
operator_split_document_test.go Added snake_case version of camelCase operators (snake case now prefered) 2022-02-11 09:05:17 +11:00
operator_split_document.go enable more linters (#1043) 2021-12-21 09:30:08 +11:00
operator_strings_test.go Minor typos (#1595) 2023-03-16 13:39:36 +11:00
operator_strings.go Fixed parsing of newline character in string expression #1430 2022-11-14 16:40:59 +11:00
operator_style_test.go Added XML decoder (#1044) 2021-12-21 15:02:07 +11:00
operator_style.go Added github action fix for parsing xml, updated linter 2022-02-07 11:55:55 +11:00
operator_subtract_test.go Minor typos (#1595) 2023-03-16 13:39:36 +11:00
operator_subtract.go Fixed sorting by date #1412 2022-11-04 12:21:12 +11:00
operator_tag_test.go Added type as an alias for tag #1195 2022-04-27 09:11:43 +10:00
operator_tag.go Added github action fix for parsing xml, updated linter 2022-02-07 11:55:55 +11:00
operator_traverse_path_test.go Fixed bug when splatting empty array #1613 2023-03-31 16:24:23 +11:00
operator_traverse_path.go Fixed bug when splatting empty array #1613 2023-03-31 16:24:23 +11:00
operator_union_test.go Variable loop - Fixes #1566 (#1577) 2023-02-28 16:40:38 +11:00
operator_union.go Added github action fix for parsing xml, updated linter 2022-02-07 11:55:55 +11:00
operator_unique_test.go Length (and some other operators) should not include head/foot comments #1231 2022-05-31 16:28:53 +10:00
operator_unique.go Length (and some other operators) should not include head/foot comments #1231 2022-05-31 16:28:53 +10:00
operator_value_test.go Fixed value operator bug #1515 2023-01-12 15:11:45 +11:00
operator_value.go Fixed value operator bug #1515 2023-01-12 15:11:45 +11:00
operator_variables_test.go Fixed npe in log #1596 2023-03-15 13:57:47 +11:00
operator_variables.go Fixed npe in log #1596 2023-03-15 13:57:47 +11:00
operator_with_test.go Fixes with operation bug #1174 2022-04-14 12:03:18 +10:00
operator_with.go Added SETPATH operator 2022-10-05 14:12:08 +11:00
operators_compare_test.go Fixed date comparison with string date #1537 2023-02-02 13:30:48 +11:00
operators_test.go Allow build without json and xml support (#1556) 2023-03-01 13:19:06 +11:00
operators.go Fixed value operator bug #1515 2023-01-12 15:11:45 +11:00
ordered_map_json.go Allow build without json and xml support (#1556) 2023-03-01 13:19:06 +11:00
ordered_map_yaml.go Allow build without json and xml support (#1556) 2023-03-01 13:19:06 +11:00
ordered_map.go Allow build without json and xml support (#1556) 2023-03-01 13:19:06 +11:00
printer_test.go Add `--nul-output|-0` flag to separate element with NUL character (#1550) 2023-03-29 09:51:55 +11:00
printer_writer.go When split expression includes an extension, dont add .yml automatically 2022-06-23 14:31:09 +10:00
printer.go Implement basic Lua output support (#1745) 2023-08-11 12:56:49 +10:00
properties_test.go Handle scalars in property files 2023-03-27 13:51:08 +11:00
shellvariables_test.go Implement shell output format (#1645) 2023-05-04 11:06:56 +10:00
stream_evaluator.go Refactored decoder responsibilities (#1402) 2022-10-28 14:16:46 +11:00
string_evaluator_test.go Refactored decoder responsibilities (#1402) 2022-10-28 14:16:46 +11:00
string_evaluator.go Refactored decoder responsibilities (#1402) 2022-10-28 14:16:46 +11:00
toml_test.go Added scalar output for TOML (#1617) 2023-04-03 15:40:06 +10:00
utils.go Implement shell output format (#1645) 2023-05-04 11:06:56 +10:00
write_in_place_handler.go Build constraint not working for non linux (#1481) 2023-01-03 15:52:01 +11:00
xml_test.go Handle scalars in csv, xml files 2023-03-27 13:54:24 +11:00
xml.go Hotfix: actually update the default xml attribute prefix #1428 2022-11-13 11:13:34 +11:00
yaml.go Refactored decoder responsibilities (#1402) 2022-10-28 14:16:46 +11:00