UNPKG

@controlplane/cli

Version:

Control Plane Corporation CLI

151 lines 4.87 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.withStandardOptions = exports.withAllOptions = exports.withGvcOptions = exports.withForceOption = exports.withOrgOptions = exports.withProfileOptions = exports.withFormatOptions = exports.withRequestOptions = exports.withDebugOptions = void 0; const functions_1 = require("../util/functions"); function withDebugOptions(yargs) { const group = 'Debug options:'; return yargs.options({ verbose: { group, alias: 'v', description: 'Enable verbose output to stderr', default: false, boolean: true, }, debug: { group, alias: 'd', description: 'Show all HTTP communications', default: false, boolean: true, }, }); } exports.withDebugOptions = withDebugOptions; function withRequestOptions(yargs) { const group = 'Request options:'; return yargs.options({ token: { group, requiresArg: true, description: 'Override the authorization token', }, endpoint: { group, requiresArg: true, description: 'Override the API URL', }, insecure: { group, alias: 'k', description: 'Ignore TLS errors', boolean: true, }, }); } exports.withRequestOptions = withRequestOptions; function withFormatOptions(yargs, moreFormat) { const group = 'Format options:'; return yargs.options({ output: { group, alias: 'o', requiresArg: true, description: 'Set the output format', choices: ['text', 'json', 'yaml', 'json-slim', 'yaml-slim', 'tf', 'names', ...(moreFormat !== null && moreFormat !== void 0 ? moreFormat : [])], }, color: { group, boolean: true, description: 'Colorize the output', default: true, }, ts: { group, requiresArg: true, description: 'Timestamp format if the output format is text (e.g., --output=text)', choices: ['iso', 'local', 'age'], }, max: { group, requiresArg: true, number: true, default: 50, description: `Maximum number of records to show. A value less than 1 will return all records.`, }, }); } exports.withFormatOptions = withFormatOptions; const profileDescription = 'Override the profile. The default profile can be set using the `cpln profile set-default` command or by setting the CPLN_PROFILE environment variable'; const orgDescription = 'Override the organization. The default organization can be set in your profile by using the `cpln profile update` command'; const gvcDescription = 'Override the global virtual cloud. The default global virtual cloud can be set in your profile by using the `cpln profile update` command'; function withProfileOptions(yargs) { const group = 'Context options:'; return yargs.options({ profile: { group, requiresArg: true, description: profileDescription, }, }); } exports.withProfileOptions = withProfileOptions; function withOrgOptions(yargs) { const group = 'Context options:'; return yargs.options({ profile: { group, requiresArg: true, description: profileDescription, }, org: { group, requiresArg: true, description: orgDescription, }, }); } exports.withOrgOptions = withOrgOptions; function withForceOption(yargs) { return yargs.options({ force: { description: 'Bypass warnings and/or safety checks', boolean: true, }, }); } exports.withForceOption = withForceOption; function withGvcOptions(yargs) { const group = 'Context options:'; return yargs.options({ profile: { group, requiresArg: true, description: profileDescription, }, org: { group, requiresArg: true, description: orgDescription, }, gvc: { group, requiresArg: true, description: gvcDescription, }, }); } exports.withGvcOptions = withGvcOptions; function withAllOptions(yargs) { return (0, functions_1.pipe)( // withGvcOptions, withStandardOptions)(yargs); } exports.withAllOptions = withAllOptions; function withStandardOptions(yargs) { return (0, functions_1.pipe)( // withFormatOptions, withRequestOptions, withDebugOptions)(yargs); } exports.withStandardOptions = withStandardOptions; //# sourceMappingURL=options.js.map