keithamus / hbs-cli

A CLI for handlebars
43 stars 26 forks source link

Unable to change output filename? #64

Closed timojuonoja closed 2 years ago

timojuonoja commented 2 years ago

Directory and extension can be configured, but why not the output file directly? Like for example: hbs template.hbs --data ./data.json --output ./folder --outputfile result.html

This naturally means that if outputfile is used, it should ignore the extension argument. Of course you can define the argument outputfile as you wish, if this feature makes sense and worth to implement.

keithamus commented 2 years ago

Hey @timojuonoja thanks for the issue!

If you want to output to a specific filename, you can use the -s or --stdout flag to output contents to stdout and pipe that to the given file using your shell's native operators. For example:

hbs template.hbs --data ./data.json --sdout > folder/result.html

Adding --outputfile is, arguably, not an ergonomic improvement over this. It also complicates the logic because --outputfile would by nature output a single file, so when given multiple files we would either have to error, or output all given templates to the specified single file:

# what does this do?
hbs *.hbs --data ./data.json --output ./folder --outputfile result.html

I think because of these issues, that it doesn't make sense to implement this, and does not seem worthwhile. I'd be interested to hear your thoughts on this though. For now I'll close this, but we can re-open if there is a sufficiently motivating use case for this flag.

timojuonoja commented 2 years ago

Valid points. I didn't take into account of multiple files at all 🙈. That example of yours using -s fulfills my need completely 👍