libyaml
libyaml copied to clipboard
Command-line utility
It would be really helpful if there was a simple yaml command-line utility, similar to how this c-implementation of mustache templates includes a mustach
tool.
See also: jq
What should the libyaml tool do?
For starters, it could parse the examples,
echo '
unqouted: string
literal-block: |
This entire block of text will be the value of the 'literal-block' key,
with line breaks being preserved.
folded: >
This entire block of text will be the value of 'folded', but this
time, all newlines will be replaced with a single space.
' | cyaml > strings.yml
Source: https://github.com/yaml/libyaml/blob/master/examples/strings.yaml
Adapted from: https://stackoverflow.com/a/31945335
Well, there are a couple of programs under the test/
directory.
Of course currently they are only available if you build from source. They are not installed.
With those tools you can do this for example:
tests/run-parser-test-suite file.yaml | tests/run-emitter-test-suite > newfile.yaml
I think having such a tool(set) installed with libyaml could be useful. I use the existing test tools often. @ingydotnet thoughts?
Yes! Something like that would be great!
Sounds good to me.
See also: https://github.com/pantoniou/libfyaml/blob/master/README.md#fy-tool-reference
Please consider exposing it during a package manager's post-install.
bash-5.0# apk add yaml
(1/1) Installing yaml (0.2.2-r1)
OK: 15 MiB in 30 packages
bash-5.0# yaml --help
bash: yaml: command not found
bash-5.0# which yaml
bash-5.0#
I was expecting to be able to stream json to this tool, and get a yaml stream from it, and vice versa.
Yeah, I would also like to have it. I just didn't find the time yet (and also have to learn how to create a binary to install)