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

Enable --template and --stdin to be used together? #36

Open
msabramo opened this issue Sep 14, 2021 · 3 comments
Open

Enable --template and --stdin to be used together? #36

msabramo opened this issue Sep 14, 2021 · 3 comments

Comments

@msabramo
Copy link
Contributor

msabramo commented Sep 14, 2021

Currently --template and --stdin are mutually exclusive.

In other words, you can use --template:

$ node cli.js --template 'How about some {red.bold chocolate} & {blue.bold peanut butter}?'
How about some chocolate & peanut butter?

and you can use data from stdin:

$ echo 'How about some chocolate & peanut butter?' | node cli.js --stdin yellow
How about some chocolate & peanut butter?

but you can't use --template with data from stdin:

$ echo 'How about some {red.bold chocolate} & {blue.bold peanut butter}?' | node cli.js --template --stdin
Input required

I think it would be cool if this were possible. The last example with echo is a little silly because it can so easily be changed to the first command, but imagine if the "chalk markup" string were a lot longer and it were in a file, say chocolate-and-peanut-butter.chalk.txt and then you could do:

$ node cli.js --stdin < chocolate-and-peanut-butter.chalk.txt
@sindresorhus
Copy link
Member

but you can't use --template with data from stdin:

Did you mean to add --template to that example?

@msabramo
Copy link
Contributor Author

but you can't use --template with data from stdin:

Did you mean to add --template to that example?

Yes, thanks.

@sindresorhus
Copy link
Member

I agree it would be useful to support this, but I also think it's weird that --template then can both accept a value and also be used as a boolean flag for stdin. I think we should then make it only a boolean flag and make the template always come as stdin or the first argument.

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

No branches or pull requests

2 participants