UNPKG

@itsmworkbench/cli

Version:

How to do a cli

19 lines (18 loc) 1.03 kB
"use strict"; //Why make Commander a type parameter? Because of versions. We decouple ourselves from the version Object.defineProperty(exports, "__esModule", { value: true }); exports.makeCli = exports.cliTc = exports.cliContext = void 0; const utils_1 = require("@laoban/utils"); const cliconfig_1 = require("./cliconfig"); function cliContext(name, version, fileOps) { return { name, version, currentDirectory: process.cwd(), env: process.env, fileOps, args: process.argv }; } exports.cliContext = cliContext; function cliTc(createCommander, addSubCommand, addCommands, execute) { return { createCommander, addSubCommand, addCommands, execute }; } exports.cliTc = cliTc; async function makeCli(context, configTc, cliTc) { return (0, utils_1.mapErrors)(await (0, cliconfig_1.loadConfig)(context.fileOps, configTc, context.currentDirectory), ({ config, cliConfigTc, configFileName }) => ({ context, config, cliConfigTc, commander: cliTc.createCommander(context, config), configFileName })); } exports.makeCli = makeCli;