UNPKG

cobolget

Version:
81 lines (80 loc) 3.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const program = require("commander"); const leven = require("leven"); const list_1 = require("./list"); const run_1 = require("./run"); const init_1 = require("./init"); const validate_1 = require("./validate"); const add_1 = require("./add"); const remove_1 = require("./remove"); const index_1 = require("./index"); const update_1 = require("./update"); const install_1 = require("./install"); const licenses_1 = require("./licenses"); const pkg = require('../package.json'); console.log(`COBOLget ${pkg.version} by Olegs Kunicins and contributors.\n`); module.exports = function (argv) { program .version(pkg.version, '-v, --version') .usage('<command> [options]'); program .command('list <keyword>') .description('List packages in the registry') .action((keyword) => list_1.list(keyword)); program .command('index <name|url>') .option('-t, --token <token>', 'Repository token for private package') .option('-o, --organization <organization>', 'Organization name for private package') .description('Import or update the package in the registry') .action((name, options) => index_1.index(name, options)); program .command('init') .description('Create manifest file') .action(() => init_1.init()); program .command('validate') .description('Validate manifest file') .action(() => validate_1.validate()); program .command('add <dependency> [version]') .option('-d, --debug', 'Add debug package to the manifest') .description('Add package to the manifest') .action((dependency, version, options) => add_1.add(dependency, version, options)); program .command('remove <dependency>') .option('-d, --debug', 'Remove debug package from the manifest') .description('Remove package from the manifest') .action((dependency, options) => remove_1.remove(dependency, options)); program .command('update') .description('Resolve dependencies and update lockfile') .action(() => update_1.update()); program .command('install') .option('-t, --token <token>', 'Team token') .description('Install dependencies from lockfile') .action((token) => install_1.install(token)); program .command('licenses') .description('List licenses of the installed packages') .action(() => licenses_1.licenses()); program .command('run <script*>') .description('Run matching script(s) defined in the manifest') .action((script) => run_1.run(script)); program .command('*', '', { noHelp: true }) .action((cmd) => { program.help(help => { const availableCommands = program.commands.map(c => c._name); const suggestion = availableCommands.find(c => leven(c, cmd) < c.length * 0.4); help = `${help}\nUnknown command '${cmd}'`; return suggestion ? `${help}, did you mean '${suggestion}'?\n` : `${help}.\n`; }); }); program.parse(argv); if (process.argv.length <= 2) { program.help(); } };