shyaml icon indicating copy to clipboard operation
shyaml copied to clipboard

Add command line option to ignore blank yaml values

Open jsh2134 opened this issue 10 years ago • 1 comments

It would be great if there was an output flag to ignore blank yaml values. Currently it outputs null

My use case is that I'm using it along with envdir to output a docker-compose file to an envdir directory

the current command: cat docker-compose.yml | shyaml get-value api.environment | grep -v null | awk -F': ' '{print $2 > ("envdir/" $1)}'

proposed fix would be something like shyaml get-value api.environment --ignore-blank

via a StackOverflow comment http://stackoverflow.com/questions/5014632/how-can-i-parse-a-yaml-file-from-a-linux-shell-script/15113891?noredirect=1#comment48491233_15113891

jsh2134 avatar May 29 '15 20:05 jsh2134

Hi, thanks for your suggestion. Actually, it's probably better to output 'null' only on request. I'm using postgres often, and you can actually set how null value should be outputted and it was usefull for me several times.

As a consequence, I would probably change shyaml to output an empty string for null values, and add a special --display-null-as VALUE options. I'm pretty much busy these days so don't expect an implementation of this right now, and I probably need to think it through a little more.

vaab avatar Jun 08 '15 05:06 vaab