Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 51 lines (44 sloc) 1.263 kB
#!/usr/bin/env node
//
// name : holler.js
// description : real-time, in-app notifications from the command line
//
// TODO: definitely handle this better using something
// like https://github.com/substack/node-optimist
if(process.argv.length < 4){
console.error("usage: holler [url:port] [type] [message|redirectUrl]?");
process.exit();
}
// define everything
var faye = require('faye'),
os = require("os"),
p = process.argv[2],
type = process.argv[3],
url = p.substring(p.length-1) == "/" ? p.substring(0,p.length-1) : p,
ops = {
"log" : 1,
"success" : 1,
"error" : 1,
"refresh" : 1,
"redirect" : 1
};
// validate notification type
if(!ops[type]){
console.error("uh oh: [type] must be one of [log, success, error, refresh, redirect]");
process.exit();
}
// create a regular old client just like a browser would
var client = new faye.Client(url+'/faye');
var notification = client.publish('/holler', {
type: type,
message: type != "refresh" ? process.argv[4] : null
});
// when done, kill this sucker
notification.callback(function() {
process.exit();
});
// if we error out, kill this still
notification.errback(function(error) {
alert('uh oh: ' + error.message);
process.exit();
});
Jump to Line
Something went wrong with that request. Please try again.