all files / src/ cli.js

0% Statements 0/15
0% Branches 0/2
0% Functions 0/1
0% Lines 0/14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                                             
/* eslint no-process-exit: 0 */
import chalk from 'chalk';
import yargs from 'yargs';
import parseCliArgs from './parse-cli-args';
 
export default function cliExeute(argv) {
  let command;
 
  try {
    command = parseCliArgs(argv);
  } catch(err) {
    console.log(chalk.red(`Failed: ${err.toString()}`));
    if (err.stack) {
      console.log(chalk.red(err.stack));
    }
    console.log('');
    yargs.showHelp();
    return Promise.resolve(1);
  }
 
  return command.execute(command.options);
}