Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 44 lines (43 sloc) 2.37 KB
#!/usr/local/bin/node
(function() {
var MUZAK_REDIRECT, argv, create, current, muzakBaby, request, rest, room, sys;
sys = require('sys');
rest = require('restler');
MUZAK_REDIRECT = 'http://hawmuzak.heroku.com';
argv = process.argv;
current = function() {
return rest.get(MUZAK_REDIRECT, {
followRedirects: false
}).on('complete', function(headers, data) {
return sys.puts('Current Muzak room is: ' + data.headers.location);
});
};
create = function() {
return rest.post(MUZAK_REDIRECT, {
data: {
url: room
}
}).on('complete', function(data, response) {
return sys.puts('New Muzak room created: ' + response.headers.location);
});
};
if (request = process.argv[2]) {
switch (request) {
case 'current':
current();
break;
case 'create':
if (room = process.argv[3]) {
create();
} else {
sys.puts("Could not create a new room. You need to supply a URL for it.");
}
break;
case 'baby':
muzakBaby = ' \n MMMMMMMMMM \n MM M MM \n M M M \n M M MM M \n M M \n M M \n M \n \nM \nM MM M \nM M M M \n M MM \n M M \n M M \n M M M M \n M MM MMM \n M M \n M \n M \n MMMMM MMMM \n ';
sys.puts(muzakBaby);
}
} else {
current();
}
}).call(this);