#!/usr/bin/env node

'use strict';

var app = require('commander');
var core = require('../');
var version = require('../package.json').version;

app
  .version(version)
  .option('-r, --record', 'Record a new test')
  .option('-u, --update', 'Update screenshots using the automated steps')
  .option(
    '-b, --browser <browser>',
    'Default: Firefox. Chrome needs extra setup (See README).'
  )
  .option(
    '-d, --dir <dir>',
    'Folder to search for the Huxleyfiles. Accepts glob patterns. Default: ' +
    ' \'**/\' (every Huxleyfile in the current and nested folders).'
  )
  .parse(process.argv);

var browser = app.browser;
// TODO: might change every mention of path to dir
// the project uses `path` instead of `dir` everywhere (more concise). The
// argument's `dir` only because that's what lots of people expect
var path = app.dir;

if (app.update) {
  core.playbackTasksAndSaveScreenshots(browser, path);
} else if (app.record) {
  core.recordTasks(browser, path);
} else {
  core.playbackTasksAndCompareScrenshots(browser, path);
}
