Currently, the go-yaml CLI takes YAML input and displays four main different outputs which you select:
- Tokens (load stack)
- Events (load stack)
- Nodes (load stack)
- YAML (dump stack)
This is wonderful and really useful for debugging situations to see where in the stack things go wrong.
However, it would be even better if we could use some of these outputs as inputs to another CLI process.
Something like this:
./go-yaml --token <<<'a: b # c' |
./go-yaml --from=tokens --YAML
The first process outputs tokens as YAML and the second process reads that YAML into the part of the loader that needs tokens, and turns the YAML into token structs and continues.
Of course, we don't have to use pipes. We could write stuff to files and mutate it and then feed it as input to different processes:
./go-yaml --token <<<'a: b # c' > tokens.yaml
vim tokens.yaml # make changes
./go-yaml --from=tokens --YAML < tokens.yaml
Or even pipe it into a program that makes changes automatically (yq comes to mind).
./go-yaml --token <<<'a: b # c' |
yq '...' |
./go-yaml --from=tokens --YAML
We are really going to want to have this going forward. It lets people test almost every situation for go-yaml situationally and without needing to write go code to do it. It allows people to show reproducible behavior and possible solutions with a few lines in a issue or pull request.
Currently, the go-yaml CLI takes YAML input and displays four main different outputs which you select:
This is wonderful and really useful for debugging situations to see where in the stack things go wrong.
However, it would be even better if we could use some of these outputs as inputs to another CLI process.
Something like this:
The first process outputs tokens as YAML and the second process reads that YAML into the part of the loader that needs tokens, and turns the YAML into token structs and continues.
Of course, we don't have to use pipes. We could write stuff to files and mutate it and then feed it as input to different processes:
Or even pipe it into a program that makes changes automatically (
yqcomes to mind).We are really going to want to have this going forward. It lets people test almost every situation for go-yaml situationally and without needing to write go code to do it. It allows people to show reproducible behavior and possible solutions with a few lines in a issue or pull request.