"use strict";
var minimist = require("minimist");
var path = require("path");
var cli_1 = require("../cli");
var config_1 = require("../config");
var files_1 = require("../files");
var Opt = require("./");
var opts_1 = require("./opts");
var prog = new cli_1.Program()
    .command('clean', 'removes all downloaded driver files from the out_dir')
    .action(clean)
    .addOption(opts_1.Opts[Opt.OUT_DIR]);
exports.program = prog;
// stand alone runner
var argv = minimist(process.argv.slice(2), prog.getMinimistOptions());
if (argv._[0] === 'clean-run') {
    prog.run(JSON.parse(JSON.stringify(argv)));
}
else if (argv._[0] === 'clean-help') {
    prog.printHelp();
}
/**
 * Parses the options and cleans the output directory of binaries.
 * @param: options
 */
function clean(options) {
    var outputDir = config_1.Config.getSeleniumDir();
    if (options[Opt.OUT_DIR].getString()) {
        if (path.isAbsolute(options[Opt.OUT_DIR].getString())) {
            outputDir = options[Opt.OUT_DIR].getString();
        }
        else {
            outputDir = path.resolve(config_1.Config.getBaseDir(), options[Opt.OUT_DIR].getString());
        }
    }
    files_1.FileManager.removeExistingFiles(outputDir);
}
//# sourceMappingURL=clean.js.map