#!/usr/bin/env node

var argv = require('optimist').argv._;
var burst = require('../lib/burst');
var config = require('../lib/config');

if (!module.parent) {
  config.get(function (err, options) {
    if (err) throw new Error(err);
    var command = argv[0];
    switch (command) {

      case 'as':
        burst.as(options.redis, argv[1]);
        break;

      case 'to':
        burst.to(options.redis, argv[1], argv[2]);
        break;

      case 'into':
        if (typeof(argv[1]) === 'number') {
          options.redis = {host: '127.0.0.1', port: argv[1]};
        } else {
          var pieces = argv[1].split(':');
          options.redis = {host: pieces[0], port: pieces[1]||6379};
        }
        config.save(options, function () {});
        break;

    }      
  });
}


@@ -128,16 +128,81 @@
 onfig');
+%0Avar log = require('../lib/log');%0Avar colors = require('colors');
 %0A%0Aif (!m
@@ -822,24 +822,596 @@
     break;%0A%0A
+      default:%0A        log('burst');%0A        log('Simple command-line file sharing for developers on the same network.');%0A        log('help', ' ');%0A        log('help', '  Connect to a Redis server:'.grey);%0A        log('help', '    burst into 10.0.0.123:6379');%0A        log('help', ' ');%0A        log('help', '  Accept a file transfer:'.grey);%0A        log('help', '    burst as ' + process.env.USER);%0A        log('help', ' ');%0A        log('help', '  Send a file:'.grey);%0A        log('help', '    burst to cam ./funny_picture.jpg');%0A        log('help', ' ');%0A        break;%0A%0A
     %7D      %0A

add help text