UNPKG

@darkobits/saffron

Version:

Yargs + Cosmiconfig for robust, configurable CLIs.

28 lines (27 loc) 847 B
import fs from "fs"; import path from "path"; import { getPackageInfo } from "./package.js"; import yargs from "./yargs.js"; function init(cb) { var _a; const hostPkg = getPackageInfo({ cwd: path.dirname(fs.realpathSync(process.argv[1])) }); yargs.showHelpOnFail(true, "See --help for usage instructions."); yargs.wrap(yargs.terminalWidth()); if ((_a = hostPkg.json) == null ? void 0 : _a.version) { yargs.version(hostPkg.json.version); } yargs.help(); void Promise.resolve(typeof cb === "function" ? cb(yargs) : void 0).then((customParser) => { if (typeof customParser !== "function") { return yargs.argv; } return yargs.parseAsync(process.argv.slice(2), customParser); }).catch((err) => { console.error(err); process.exit(1); }); } export { init as default }; //# sourceMappingURL=init.js.map