Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
trixpan opened this issue Feb 8, 2015 · 3 comments
Open

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

trixpan opened this issue Feb 8, 2015 · 3 comments
Labels

Comments

@trixpan
Copy link

trixpan commented Feb 8, 2015

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

@vaab
Copy link
Member

vaab commented Feb 8, 2015

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).

@paleozogt
Copy link

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.

@vaab
Copy link
Member

vaab commented Aug 17, 2015

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 vaab added the idea label Sep 27, 2015
gio8tisu pushed a commit to gio8tisu/shyaml that referenced this issue Aug 6, 2020
Use custom argparse Action (FileInputAction) to open given
file (or stdin if file is "-" or not given).
Update usage and help messages and README examples.

Issue 0k#11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants