#!/usr/bin/env babel-node

import program from 'commander'

import local from './capture/local'
import remote from './capture/remote'
import scenarioHelpers from '../test/helpers/scenarios'

program
  .description('Capture FS events')
  .option('-l, --local', 'Local events only')
  .option('-r, --remote', 'Remove events only')
  .parse(process.argv)

const sides = []
if (program.local || !program.remote) sides.push(local)
if (program.remote || !program.local) sides.push(remote)

const captureScenariosEvents = async (scenarios, sides) => {
  try {
    console.log('test/scenarios/')
    for (let scenario of scenarios) {
      console.log(`  ${scenario.name}/`)
      for (let side of sides) {
        try {
          const outputFilename = await side.captureScenario(scenario)
          console.log(`    \x1B[1;32m✓\x1B[0m ${side.name}/${outputFilename}`)
        } catch (err) {
          console.log(`    \x1B[1;31m✗\x1B[0m ${side.name}/`)
          console.error('\x1B[1;31m', err, '\x1B[0m')
        }
      }
    }
    console.log('✨  Done.')
  } catch (err) {
    console.error(err)
  }
}

captureScenariosEvents(scenarioHelpers.scenarios, sides)

@@ -51,16 +51,40 @@
 mmander'
+%0Aimport path from 'path'
 %0A%0Aimport
@@ -252,16 +252,47 @@
 vents')%0A
+  .arguments('%5Bscenarios...%5D')%0A
   .optio
@@ -401,16 +401,532 @@
 .argv)%0A%0A
+const scenarioArgPattern = new RegExp(path.join(%0A  '%5E.*', '?test', 'scenarios', %60(%5B%5E$%7Bpath.sep%7D%5D+)%60, '?.*$'))%0A%0Aconst scenarios = (args) =%3E %7B%0A  if (args.length === 0) return scenarioHelpers.scenarios%0A%0A  return args.map(arg =%3E %7B%0A    const match = arg.match(scenarioArgPattern)%0A    if (match) %7B%0A      return scenarioHelpers.scenarioByPath(path.join(%0A        __dirname, '..', 'test', 'scenarios', match%5B1%5D, 'scenario.js'))%0A    %7D else %7B%0A      console.error(%60Invalid argument: $%7Barg%7D%60)%0A      process.exit(1)%0A    %7D%0A  %7D)%0A%7D%0A%0A
 const si
@@ -1697,33 +1697,31 @@
 scenario
-Helpers.scenarios
+s(program.args)
 , sides)

Allow running 1 or more scenarios