// @flow

import yargs from 'yargs';
import { printErrors } from '../printErrors';
import { visit } from './visit';

export function run() {
  try {
    // eslint-disable-next-line no-unused-expressions
    yargs
      // Use yargs.commandDir method to initialize a directory of commands
      // Ref: https://github.com/yargs/yargs/blob/e87f4873012e3541325e7ec6dafb11a93b5717e0/docs/advanced.md#commanddirdirectory-opts
      .commandDir('../commands', { visit })
      // Require entry of at least one command after `lagoon`, such as `lagoon login`.
      // `lagoon` by itself has no assigned function at the moment.
      .demandCommand()
      // .strict(): Error out on non-demanded or non-described command line argument
      // .argv: Get arguments as an object
      .strict().argv;
  } catch (err) {
    const exitCode = printErrors(console.error, 'Uncaught error:', err);
    process.exit(exitCode);
  }
}

run();

@@ -915,12 +915,4 @@
 %7D%0A%7D%0A
-%0Arun();%0A

Fix double run