wwkimball / yamlpath

YAML/JSON/EYAML/Compatible get/set/merge/validate/scan/convert/diff processors using powerful, intuitive, command-line friendly syntax.
https://github.com/wwkimball/yamlpath/wiki
ISC License
120 stars 23 forks source link

Allowing for multiple files to be changed with yaml-set #53

Closed aharper273 closed 4 years ago

aharper273 commented 4 years ago

If a user has multiple yaml files and would like the value for each key to change uniformly, there doesn't seem to be functionality to support this within yamlpath.

Describe the solution you'd like Allow a user to specify multiple filesnames and/or use a wildcard. I.E. yaml-set --change=food.salad --values"caesar" foo.yaml bar.yaml and yaml-set -change=food.salad --values="Cobb" *.yaml

Obviously it is possible to find a way to loop as needed, but this this would be a nice feature to be build in.

Also, wanted to say that this is extremely helpful tool and it works wonderfully! Thank you for making it!

wwkimball commented 4 years ago

This was a conscious decision because yamlpath "plays nicely" with other tools and yaml-set's atomic mission is to very carefully make one precise change to a single fixed, known YAML/Compatible structure. If you are confident that you have multiple files which yaml-set can safely manipulate, chain it together with find. Please try this: find /where/your/yaml/files/are/ -type f -name '*.yaml' -exec yaml-set --change=food.salad --value=ceasar {} \; Even more interesting, parallel processing becomes possible when adding xargs to this mix.

Chaining yaml-set with find like this gives a much more granular control over which files to affect than a simple skeleton mask can provide; find can exclude files that a skeleton mask like *.yaml simply cannot. Using find further enables processing files recursively through an entire directory structure. The possibilities for granular selection become even more interesting when chaining with other tools (like grep, etc.).

Chaining tools like this provides far greater flexibility than any one tool can provide alone and is a notably powerful advantage to command-line use.

Thank you for using yaml-path! I'm very glad to see it helping to make other people's lives easier.