coffeecup
coffeecup copied to clipboard
Add support for stdin
I didn't do a pull request. You have a few waiting anyway.
I suggest something like, to stay in line with the rest of the code and conventions, to modify cli.coffee and append a switch e.g. -i for processing stdin.
['-i', '--stdin', 'accept input over standard input interface stdin']
Then add
codeIn = ""
stdin = process.openStdin()
# and under run...
if options.stdin
# Buffer streams of data and concat to string until finished
stdin.on 'data', (buffer) -> codeIn += buffer.toString() if buffer
stdin.on 'end', -> log coffeecup.render codeIn
This will allow for something like
$ coffee -p -b myfile.litcoffee | js2coffee | coffeecup -i
As a little round-trip since coffeescript cli tool doesn't really allow a unmangle of the .litcoffee files yet.