Code coverage report for lib/cli.js

Statements: 100% (20 / 20)      Branches: 100% (2 / 2)      Functions: 100% (6 / 6)      Lines: 100% (20 / 20)      Ignored: none     

All files » lib/ » cli.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 501         1   1           1 1 1     1 1 3   1 2 2 2 2 1   1                 1   2           2     1
var async = require('async'),
  bag = require('bagofcli'),
  prompt = require('prompt'),
  Roombox = require('./roombox');
 
function _start(args) {
 
  var opts = {
    path: args.path,
    baudrate: args.baudRate,
    dir: 'data/'
  };
 
  var roombox = new Roombox();
  roombox.start(opts, function () {
    async.whilst(_check, _prompt, bag.exit);
  });
 
  var answer;
  function _check() {
    return answer !== 'e';
  }
  function _prompt(cb) {
    prompt.start();
    prompt.get(['Select track'], function (err, result) {
      answer = result['Select track'];
      if (answer !== 'e') {
        roombox.play(answer, cb);
      } else {
        cb();
      }
    });
  }
}
 
/**
 * Execute Roombox CLI.
 */
function exec() {
 
  var actions = {
    commands: {
      start: { action: _start }
    }
  };
 
  bag.command(__dirname, actions);
}
 
exports.exec = exec;