bin/kbox.js
/*
 * Find the correct cli task and run it.
 */
Find the correct cli task and run it.
Find the correct cli task and run it .
function processTask(app) {
  var appResult = (function() {
    if (!app) {
      return null;
    } else if (argv.payload.length === 0) {
      return null;
    } else {
      var appPayload = argv.payload.slice(0);
      if (appPayload[0] !== app.name) {
        appPayload.unshift(app.name);
      }
      return kbox.tasks.find({
        payload: appPayload,
        options: argv.options,
        rawOptions: argv.rawOptions
      });
    }
  })();
  var globalResult = kbox.tasks.find(argv);
  var result = (function() {
    if (appResult) {
      return appResult;
    } else {
      return globalResult;
    }
  })();
  if (!result) {
    kbox.tasks.showMenu(kbox.tasks.getTaskTree(), app);
  } else if (kbox.tasks.isBranch(result)) {
    kbox.tasks.showMenu(result, app);
  } else if (kbox.tasks.isTask(result)) {
    kbox.tasks.run(result, function(err) {
      if (err) {
        handleError(err);
      }
    });
  } else {
    assert(false);
  }
}
function processTask ( app ) { var appResult = ( function ( ) { if ( ! app ) { return null ; } else if ( argv . payload . length === 0 ) { return null ; } else { var appPayload = argv . payload . slice ( 0 ) ; if ( appPayload [ 0 ] !== app . name ) { appPayload . unshift ( app . name ) ; } return kbox . tasks . find ( { payload : appPayload , options : argv . options , rawOptions : argv . rawOptions } ) ; } } ) ( ) ; var globalResult = kbox . tasks . find ( argv ) ; var result = ( function ( ) { if ( appResult ) { return appResult ; } else { return globalResult ; } } ) ( ) ; if ( ! result ) { kbox . tasks . showMenu ( kbox . tasks . getTaskTree ( ) , app ) ; } else if ( kbox . tasks . isBranch ( result ) ) { kbox . tasks . showMenu ( result , app ) ; } else if ( kbox . tasks . isTask ( result ) ) { kbox . tasks . run ( result , function ( err ) { if ( err ) { handleError ( err ) ; } } ) ; } else { assert ( false ) ; } }
Find the correct cli task and run it.
Find the correct cli task and run it .
// Search for a task with the app name. // Search for a task without the app name. // For now just use the app result if it exists. // We ended up with a branch, so display task tree. // We ended up with a branch, so display task tree. // We found a task, so run it. // Whoops an error happened. // This should never happen.