shyaml icon indicating copy to clipboard operation
shyaml copied to clipboard

it would be a great idea if you pass a file as parameter...

Open trixpan opened this issue 10 years ago • 3 comments

Pipes are great but not always handy and in certain ways, shouldn't truly be necessary if instead a "file.open" was used.

trixpan avatar Feb 08 '15 13:02 trixpan

Hi, my first go was to avoid making argument parsing complicated. I wanted to avoid all the hassle. I know that there are marvelous library existing to parse the command line, and maybe I should go to choose one of them now.

Thou, I'm curious of which case you couldn't use pipes. I can't realy see an example. And pipes are often much more agile to use. You don't have to work on files. And writing temporary files is cumbersome.

Anyway, I think your request is valid, and that shyaml probably need to have the ability to read directly its input from file. Any PR going into this direction is encouraged.

I may not work on it myself now, as I don't have many time, and I consider this as a new feature, and not something really impeding the use of shyaml. (unless you can find me good examples where you can't use stdin to feed shyaml).

vaab avatar Feb 08 '15 13:02 vaab

Here's a use-case that pipes makes pretty hard: using find, xargs, and shyaml. With a command-line file input, this is easy:

find . -iname \*.yaml | xargs -Ifile shyaml --file file get-value foo.bar

but with the pipe requirement, you have to do something like

find . -iname \*.yaml | xargs -file cat file | shyaml get-value foo.bar

which doesn't work, because the pipe syntax is ambiguous.

paleozogt avatar Aug 14 '15 21:08 paleozogt

I would suggest using:

find . -iname \*.yaml | while read file; do cat "$file" | shyaml get-value foo.bar; done

Anyway, I'm still in favor to add a command line argument to shyaml.

vaab avatar Aug 17 '15 06:08 vaab