node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »


Drink Coffee, or JavaScript. Daily.


Drink is a simple, and easy to use Terminal Helper. It helps you keep sessions alive, process input, send output, and more in a quirky or direct sytnax.

No. Seriously. It has humour or not for those serious types. Both Javascript and Coffeescript are supported, examples shown below are in coffee-script.


The easiest way to install Drink is to utilize npm

npm install drink

Then inside your script, require drink.

drink = require 'drink'

Use Cases

What can drink be used for? Simple. A lot. Everything from CLI to IRC Clients to Zebra Tracking Utilities. Seriously. Drink allows you to simply keep alive a terminal session. Think about that. You can make a Twitter Client, Reddit Poster, quite literally anything.

Now you see it's power.


Utilizing Drink is very simple. For a basic keep alive all you need is this:

Coffee = drink process
do Coffee.stir

This will initialize drink with the current terminal process allowing it to keep your session alive and accept input information. More often than naught you might want it to process for a certain amount of times or at a specific rate, Drink supports this:

# Default Option Settings 
# rate - the amount of time in-between pours, in milliseconds. 
# for - the amount of pours you want drink to process. 
# debug - numerical / boolean, 2 is to show pour amounts. 
Coffee = drink processrate: 1000for: 0debug: false
# Begin Stirring 
do Coffee.stir


In Drink, keeping the Session alive in terminal is considered stirring, just as with the basic usage.

Coffee = drink process

For those who think they may not remember this, or are confused as to what it does, you can also use it's aliased function start

Coffee = drink process


To stop the session from stirring you simply spill the session or cup out.

Coffee = drink process
# Initialize the session 
# Kill or Exit the session. 

Once again, this also has an alias called exit

Terminal Output Methods


Are you one of those who don't like fully gulping down a cup? Well just sip on it. Spec Note: This may change

Sipping allows you to push to console or terminal without appending newlines.

Coffee = drink process
Coffee.sip("Hello ")

Aliased Method: print


Maybe you do prefer to gulp down some information; We certainly can help provide that functionality. Spec Note: This may change

Same as sip, with a newline appended.

Coffee = drink process

Aliased Method: printnl

Terminal Input Methods

Single Character Input

Useful for those Y/N Questions a lot of people seem to bring up in conversation. For those quick little bursts of information we simply use an onTap method with a nice callback.

Coffee = drink process
  # We want to exit now. They used a semi-colon, my weakness! 
  # We also bind this, so you can easily manipulate the parent. 

Aliased Method: onKey

There is a little more functionality, such as meta-keys:

Coffee.onTap({ name: 'd', ctrl: true }, ->
  this.gulp "Hello World!"

Supports ctrl, meta, shift

Data Input

For those who need a mouthfull of information we simply use an onFill method with a nice callback.

Coffee = drink process
  # We want to exit now. They typed exit! 
  # We also bind this, so you can easily manipulate the parent. 

Aliased Method: onData

Let's say you just want to get information, in general? The first argument passed is a binary output from the process, do with this as you wish. The second argument passed is a string output that has been *pre-trimmed by drink. Enjoy~

Coffee.onFill(null, (chunk, data) ->
  this.gulp "You said: " + data