'use strict';

var commander = require('commander');
var chalk = require('chalk');
var errors = require('./lib/errors.cjs.js');
var version = require('./lib/version.cjs.js');
var index = require('./commands/index.cjs.js');

function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }

var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);

const main = (argv) => {
  commander.program.name("backstage-cli").version(version.version);
  index.registerCommands(commander.program);
  commander.program.on("command:*", () => {
    console.log();
    console.log(chalk__default.default.red(`Invalid command: ${commander.program.args.join(" ")}`));
    console.log();
    commander.program.outputHelp();
    process.exit(1);
  });
  commander.program.parse(argv);
};
process.on("unhandledRejection", (rejection) => {
  if (rejection instanceof Error) {
    errors.exitWithError(rejection);
  } else {
    errors.exitWithError(new Error(`Unknown rejection: '${rejection}'`));
  }
});
main(process.argv);
//# sourceMappingURL=index.cjs.js.map
