dist/autocomplete.js
function getMatchData(input, cb) {
  var string = input.context;
  var cmd = input.match;
  var midOption = String(string).trim().slice(0, 1) === '-';
  var afterOption = input.option !== undefined;
  if (midOption === true && !cmd._allowUnknownOptions) {
    var results = [];
    for (var i = 0; i < cmd.options.length; ++i) {
      var long = cmd.options[i].long;
      var short = cmd.options[i].short;
      if (!long && short) {
        results.push(short);
      } else if (long) {
        results.push(long);
      }
    }
    cb(results);
    return;
  }

  function handleDataFormat(str, config, callback) {
    var data = [];
    if (_.isArray(config)) {
      data = config;
    } else if (_.isFunction(config)) {
      var cbk = config.length < 2 ? function () {} : function (res) {
        callback(res || []);
      };
      var res = config(str, cbk);
      if (res && _.isFunction(res.then)) {
        res.then(function (resp) {
          callback(resp);
        }).catch(function (err) {
          callback(err);
        });
      } else if (config.length < 2) {
        callback(res);
      }
      return;
    }
    callback(data);
    return;
  }

  if (afterOption === true) {
    var opt = strip(input.option).trim();
    var shortMatch = _.find(cmd.options, { short: opt });
    var longMatch = _.find(cmd.options, { long: opt });
    var match = longMatch || shortMatch;
    if (match) {
      var config = match.autocomplete;
      handleDataFormat(string, config, cb);
      return;
    }
  }

  var conf = cmd._autocomplete;
  conf = conf && conf.data ? conf.data : conf;
  handleDataFormat(string, conf, cb);
  return;
}
function getMatchData(input, cb) {
  var string = input.context;
  var cmd = input.match;
  var midOption = String(string).trim().slice(0, 1) === '-';
  var afterOption = input.option !== undefined;
  if (midOption === true && !cmd._allowUnknownOptions) {
    var results = [];
    for (var i = 0; i < cmd.options.length; ++i) {
      var long = cmd.options[i].long;
      var short = cmd.options[i].short;
      if (!long && short) {
        results.push(short);
      } else if (long) {
        results.push(long);
      }
    }
    cb(results);
    return;
  }

  function handleDataFormat(str, config, callback) {
    var data = [];
    if (_.isArray(config)) {
      data = config;
    } else if (_.isFunction(config)) {
      var cbk = config.length < 2 ? function () {} : function (res) {
        callback(res || []);
      };
      var res = config(str, cbk);
      if (res && _.isFunction(res.then)) {
        res.then(function (resp) {
          callback(resp);
        }).catch(function (err) {
          callback(err);
        });
      } else if (config.length < 2) {
        callback(res);
      }
      return;
    }
    callback(data);
    return;
  }

  if (afterOption === true) {
    var opt = strip(input.option).trim();
    var shortMatch = _.find(cmd.options, { short: opt });
    var longMatch = _.find(cmd.options, { long: opt });
    var match = longMatch || shortMatch;
    if (match) {
      var config = match.autocomplete;
      handleDataFormat(string, config, cb);
      return;
    }
  }

  var conf = cmd._autocomplete;
  conf = conf && conf.data ? conf.data : conf;
  handleDataFormat(string, conf, cb);
  return;
}
function getMatchData ( input , cb ) { var string = input . context ; var cmd = input . match ; var midOption = String ( string ) . trim ( ) . slice ( 0 , 1 ) === '-' ; var afterOption = input . option !== undefined ; if ( midOption === true && ! cmd . _allowUnknownOptions ) { var results = [ ] ; for ( var i = 0 ; i < cmd . options . length ; ++ i ) { var long = cmd . options [ i ] . long ; var short = cmd . options [ i ] . short ; if ( ! long && short ) { results . push ( short ) ; } else if ( long ) { results . push ( long ) ; } } cb ( results ) ; return ; } function handleDataFormat ( str , config , callback ) { var data = [ ] ; if ( _ . isArray ( config ) ) { data = config ; } else if ( _ . isFunction ( config ) ) { var cbk = config . length < 2 ? function ( ) { } : function ( res ) { callback ( res || [ ] ) ; } ; var res = config ( str , cbk ) ; if ( res && _ . isFunction ( res . then ) ) { res . then ( function ( resp ) { callback ( resp ) ; } ) . catch ( function ( err ) { callback ( err ) ; } ) ; } else if ( config . length < 2 ) { callback ( res ) ; } return ; } callback ( data ) ; return ; } if ( afterOption === true ) { var opt = strip ( input . option ) . trim ( ) ; var shortMatch = _ . find ( cmd . options , { short : opt } ) ; var longMatch = _ . find ( cmd . options , { long : opt } ) ; var match = longMatch || shortMatch ; if ( match ) { var config = match . autocomplete ; handleDataFormat ( string , config , cb ) ; return ; } } var conf = cmd . _autocomplete ; conf = conf && conf . data ? conf . data : conf ; handleDataFormat ( string , conf , cb ) ; return ; }
Takes a known matched command, and reads
the applicable data by calling its autocompletion
instructions, whether it is the command's
autocompletion or one of its options.

@param {Object} input
@param {Function} cb
@return {Array}
@api private
Takes a known matched command and reads the applicable data by calling its autocompletion instructions whether it is the command s autocompletion or one of its options .