api
Version:
Magical SDK generation from an OpenAPI definition 🪄
32 lines • 1.31 kB
JavaScript
import { Command } from 'commander';
import updateNotifier from 'update-notifier';
import commands from './commands/index.js';
import logger from './logger.js';
import { PACKAGE_NAME, PACKAGE_VERSION } from './packageInfo.js';
import { classifyInvocation, dispatchToRestlessCli } from './router.js';
const cliArgs = process.argv.slice(2);
if (classifyInvocation(cliArgs) === 'restless') {
dispatchToRestlessCli(cliArgs);
}
else {
updateNotifier({ pkg: { name: PACKAGE_NAME, version: PACKAGE_VERSION } }).notify();
void (async () => {
const program = new Command();
program.name(PACKAGE_NAME);
program.version(PACKAGE_VERSION);
/**
* Instead of using Commander's `executableDir` API for loading in external command files we're
* programatically doing it like this because it's cleaner for us to let Commander manage option
* and argument parsing within this file than having each command manage that itself.
*/
Object.entries(commands).forEach(([, cmd]) => {
program.addCommand(cmd);
});
await program.parseAsync(process.argv).catch(err => {
if (err.message)
logger(err.message, true);
process.exit(1);
});
})();
}
//# sourceMappingURL=bin.js.map