UNPKG

@oblique/cli

Version:

Command Line Interface to manage Oblique projects

45 lines (41 loc) 2.36 kB
#!/usr/bin/env node /** * @file Oblique, The front-end framework for your Swiss branded UI. * @copyright 2020 - 2025 Federal Office of Information Technology, Systems and Telecommunication FOITT {@link https://www.bit.admin.ch} * @version 13.3.0 (released on 2025-06-12, supported at least until 2026-02-28) * @author Oblique team, FOITT, BS-BSC-EN4 <oblique@bit.admin.ch> * @license MIT {@link https://github.com/oblique-bit/oblique/blob/master/LICENSE} * @see https://oblique.bit.admin.ch */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleAction = handleAction; exports.getMaxCommandLength = getMaxCommandLength; const tslib_1 = require("tslib"); const extra_typings_1 = require("@commander-js/extra-typings"); const cliPackage = tslib_1.__importStar(require("../package.json")); const ob_new_1 = require("./new/ob-new"); const cli_utils_1 = require("./utils/cli-utils"); const ob_update_1 = require("./update/ob-update"); extra_typings_1.program .name('ob') .description(cliPackage.description) .version(cliPackage.version, cli_utils_1.optionDescriptions.ob.version.flags, cli_utils_1.optionDescriptions.ob.version.description) .helpOption(cli_utils_1.optionDescriptions.ob.help.flags, cli_utils_1.optionDescriptions.ob.help.description) .usage((0, cli_utils_1.commandUsageText)('<command>')) .addHelpText('beforeAll', (0, cli_utils_1.titleText)(`How to use the ${cli_utils_1.obTitle}`.toUpperCase(), '')) .addHelpText('after', (0, cli_utils_1.createAdditionalHelpText)('\nExample usages:\n', cli_utils_1.obExamples, getMaxCommandLength(cli_utils_1.obExamples))) .action(handleAction) .showSuggestionAfterError(true) .showHelpAfterError('(Add --help for additional information)'); const obNewCommandConfigured = (0, ob_new_1.createObNewCommand)(); const obUpdateCommandConfigured = (0, ob_update_1.createObUpdateCommand)(); extra_typings_1.program.addCommand(obNewCommandConfigured); extra_typings_1.program.addCommand(obUpdateCommandConfigured); extra_typings_1.program.parse(); function handleAction(options) { (0, cli_utils_1.startObCommand)(cli_utils_1.runObCommand, 'Oblique CLI completed in', options); } function getMaxCommandLength(examples) { return examples.map(entry => entry.command.length).reduce((max, length) => (length > max ? length : max), 0); }