Display --help output if no arguments passed to unfluff CLI
Closed this issue · 1 comments
I installed using npm i unfluff -g
and accidentally typed % unfluffed
on the CLI and it seems like unfluff just sits there waiting for some sort of input.
Not sure if you want to check if any input or arguments were passed to the unfluff command and just show the help/usage output.
The idea is to be consistent with other standard unix command line tools like cat
, sort
, uniq
, etc.
If you don't add any command line options, they assume the input will come from stdin (what the user types in). This lets you chain commands together like in the README:
curl -s "http://somesite.com/page" | unfluff
In other words, curl
downloads the page and then pipes the data into unfluff
.
Because of this behavior, you can chain programs together to do all sorts of cool stuff:
curl -s "http://www.polygon.com/2014/6/26/5842180/shovel-knight-review-pc-3ds-wii-u" | unfluff | tr -c '[:alnum:]' '[\n*]' | sort | uniq -c | sort -nr | head -10
That would use curl
to download the page, unfluff
to extract the text, tr
to put each word of text on a separate line, sort
to put common words together in order, uniq
to count how many times each word shows up together and put the count next to it, sort
again to order by the number of occurances, and finally head
to only keep the top 10 lines. In other words, that will tell you the top 10 most frequent words in the webpage.
This behavior is weird if you aren't used to it, but it's pretty standard unix behavior that makes it more useful in a lot of cases since you can then chain things together.