UNPKG

zcatalyst-cli

Version:

Command Line Tool for CATALYST

40 lines (39 loc) 2.16 kB
'use strict'; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Catalyst = void 0; const commander_1 = require("commander"); const client_1 = require("./client"); const runtime_store_1 = __importDefault(require("./runtime-store")); const fs_1 = require("./util_modules/fs"); const constants_1 = require("./util_modules/constants"); const ansi_colors_1 = require("ansi-colors"); const packageJson = runtime_store_1.default.get('cli.package'); const { description, version } = packageJson ? packageJson : (() => { const pkg = fs_1.SYNC.readPackageJson(); if (!pkg) { console.error('Package corrupted!!. Re-install zcatalyst-cli and try again.'); process.exit(1); } runtime_store_1.default.set('cli.package', pkg); return pkg; })(); const program = new commander_1.Command(); program.description(description); program.version(version, '-v, --version', 'Print the Catalyst CLI version number'); program.option('-p, --project <name|project_id>', 'Specify the Catalyst project to be used for a command'); program.option('--token <token>', 'Supply an authentication token for a command'); program.option('--dc <us|eu|in|au>', 'Supply a data center for a command'); program.option('--org <org_id>', 'Supply a Org ID to be used for a command'); program.option('--verbose', 'Change the log level to verbose for debugging purposes'); program.helpOption('-h, --help', 'Display help for a Catalyst command'); program.showSuggestionAfterError(); program.showHelpAfterError(`For more usage information use the ${(0, ansi_colors_1.bold)('catalyst help')} command`); program.addHelpText('before', fs_1.SYNC.readFile(constants_1.TEMPLATE.banner, 'utf-8') || ''); program.addHelpText('afterAll', `\nFor detailed documentations please visit ${(0, ansi_colors_1.underline)('https://docs.catalyst.zoho.com/en/cli/v1/cli-command-reference/')}`); process.env['ZCATALYST_CLI_VERSION'] = version; exports.Catalyst = new client_1.Client(program);