UNPKG

@controlplane/cli

Version:

Control Plane Corporation CLI

150 lines 4.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.withDebugOptions = withDebugOptions; exports.withRequestOptions = withRequestOptions; exports.withFormatOptions = withFormatOptions; exports.withProfileOptions = withProfileOptions; exports.withOrgOptions = withOrgOptions; exports.withForceOption = withForceOption; exports.withGvcOptions = withGvcOptions; exports.withAllOptions = withAllOptions; exports.withStandardOptions = withStandardOptions; 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, }, }); } 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, }, }); } 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', 'crd', '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.`, }, }); } 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, }, }); } function withOrgOptions(yargs) { const group = 'Context options:'; return yargs.options({ profile: { group, requiresArg: true, description: profileDescription, }, org: { group, requiresArg: true, description: orgDescription, }, }); } function withForceOption(yargs) { return yargs.options({ force: { description: 'Bypass warnings and/or safety checks', boolean: true, }, }); } 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, }, }); } function withAllOptions(yargs) { return (0, functions_1.pipe)( // withGvcOptions, withStandardOptions)(yargs); } function withStandardOptions(yargs) { return (0, functions_1.pipe)( // withFormatOptions, withRequestOptions, withDebugOptions)(yargs); } //# sourceMappingURL=options.js.map