#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
// warnings: no tanks
// hides ExperimentalWarning: The fs.promises API is experimental
process.env.NODE_NO_WARNINGS = '1';
/**
 * Dependencies
 */
const cli_1 = require("./cli");
const version_1 = require("./cli/version");
const chalk_1 = tslib_1.__importDefault(require("chalk"));
const help_1 = require("./cli/help");
const utils_1 = require("./cli/helpers/utils");
// import { capture } from './capture'
/**
 * Main function
 */
async function main() {
    // react shut up
    process.env.NODE_ENV = 'production';
    // create a new CLI with our subcommands
    const cli = cli_1.CLI.new({
        version: version_1.Version.new(),
    });
    // parse the arguments
    const result = await cli.parse(process.argv.slice(2));
    if (result instanceof help_1.HelpError) {
        console.error(result.message);
        return 1;
    }
    else if (utils_1.isError(result)) {
        console.error(result);
        return 1;
    }
    console.log(result);
    return 0;
}
process.on('SIGINT', () => {
    process.exit(0); // now the "exit" event will fire
});
/**
 * Run our program
 */
if (require.main === module) {
    main()
        .then(code => {
        if (code !== 0) {
            process.exit(code);
        }
    })
        .catch(err => {
        console.error(chalk_1.default.redBright.bold('Error: ') + err.stack);
        process.exit(1);
    });
}
