I have been using the coffee console as a calculator for quite some time. Conveniently!
And recently I wondered - why not try to write a CoffeeScript CLI script from beginning to end? And wrote!
')
For the test, I took my puzzle with a batch resize of pictures. In general, there is a scrite on bash, but it is terrible and mysterious.
I also wanted to make a decent utility, with help, startup keys, beautiful information output and all that.
On review, it turned out that writing to CS for the console is no more difficult than on the same Perl or Ruby, or even simpler:
- there are lots of modules for all occasions that do their job well
- there is npm, which automates the deployment process and resolves all dependencies with such ease that it just takes your breath away
- there is an asynchronous operation of the "iskaropki"
Approximate view of what happened - on the screen.
You can see the code in the
repository on Github.
You can install as follows:
First, we put a binary ImageMagick, from where it is put there, if not yet.
then do
npm install image-batch-resizer -g
And that's all. You can try
$ image-batch-resizer -d ./image_dir
Fast, convenient, usable.
With readable sources.
Ps.
I wrote important and forgot, as usual, to highlight the main thing.
The essence of the post is not that you can write a resize script.
The bottom line is that in CoffeeScript it is possible and necessary (because it is convenient) to write anything, this is not some sort of “share-toy”. News technology node node allows you to solve any problems, it is as good as any other based on modern high-level languages.
Yes, it is unusual, but as serious as Perl, Ruby, or whatever you like.