Expand command line arguments into the format we need to pass
to `app.cli.process()`.

@param {Object} `app` Application instance
@param {Object} `argv` argv object, parsed by minimist
@param {Array} `options.first` The keys to pass to `app.cli.process()` first.
@param {Array} `options.last` The keys to pass to `app.cli.process()` last.
@param {Array} `options.keys` Flags to whitelist
@return {Object} Returns the `argv` object with sorted keys.
function processArgv(app, argv, options) {
  var opts = utils.extend({}, options);
  if (opts.expand === false || argv.expand === 'false') {
    return argv;
  }

  argv = utils.expandArgs(argv, opts);
  return sortArgs(app, argv, opts);
}