var exec = require('child_process').exec;
var parseWrk = require('./lib/parseWrk');
var util = require("util");

function wrk(opts, callback) {
  var cmd = opts.path || 'wrk';

  if (opts.threads)
    cmd += ' -t' + opts.threads;
  if (opts.connections)
    cmd += ' -c' + opts.connections;
  if (opts.duration)
    cmd += ' -d' + opts.duration;
  if (opts.script)
    cmd += ' -s' + opts.script;
  if (opts.timeout)
    cmd += ' --timeout ' + opts.timeout;
  if (opts.rate)
    cmd += ' -R' + opts.rate;
  if (opts.printLatency)
    cmd += ' --latency ';
  if (opts.headers) {
    Object.keys(opts.headers).forEach(function(key) {
      cmd += util.format(' -H  \'%s: %s\'', key,  opts.headers[key]);
    })
  }

  cmd += ' ' + opts.url;
  opts.debug && console.log(cmd);
  var child = exec(cmd, function(error, stdout, stderr) {
    if (opts.debug) {
      stdout && console.log(stdout);
      stderr && console.error(stderr);
    }
    if (error) {
      return callback(error);
    }

    callback(null, parseWrk(stdout));
  });
}

module.exports = wrk;
module.exports.co = function(opts) {
  return function(callback) {
    wrk(opts, callback);
  }
};

@@ -707,16 +707,119 @@
 %7D)%0A  %7D%0A%0A
+  // the caller may have requested that we pass options to the exec%0A  const %7B execOptions=%7B%7D %7D = opts%0A%0A
   cmd +=
@@ -892,16 +892,29 @@
 xec(cmd,
+ execOptions,
  functio

add support for execOptions, passing through options to child_process.exec