ddopson / underscore-cli

Command-line utility-belt for hacking JSON and Javascript.
Other
1.72k stars 83 forks source link

bad example #5

Closed timkuijsten closed 12 years ago

timkuijsten commented 12 years ago

Although I really like this project, the point in the documentation about "This is what it takes to simply echo stdin" is too contrived.

Instead of the given code, the following much simpler one-liner will suffice: cat foo.json | node -e 'process.stdin.resume(); process.stdin.pipe(process.stdout);'

Not that horrible imho. Please use a better example (or update the code in the docs) since node even mentions [1] the above one-liner as an example of how easy it is to write a Unix cat program with it.

[1] http://nodejs.org/api/stream.html#stream_stream_pipe_destination_options

ddopson commented 12 years ago

While you are technically correct that one can implement vanilla "cat" by piping the input directly to the output using "only" 60 characters of script, that doesn't provide the flexibility to edit or change the input at all. Doing "cat -n" or "grep" or anything else would indeed require the full-on example I presented. Since you are almost always going to want to consume and process the input in some way (else you would just use "cat"), I think my example is accurate.