UNPKG

@formatjs/cli

Version:

A CLI for formatjs.

1 lines 14.3 MB
{"version":3,"file":"formatjs","names":["path","fs","process","commander","os","path","util","path","path","path","util","path","fs","fs","path","stream_1","path","path","stream_1","path","fs","util","path","path","path","path","path","path","path","path","path","path","path","path","_copy","_empty","_ensure","_json","_mkdirs","_move","_outputFile","_pathExists","_remove","clearLine","LEVEL_COLORS","label","debug","require","createRequire","globSync","glob","stringify","stringifyNs","BUILTIN_FORMATTERS","compile","isBuiltinFormatter","compile","TYPE","isArgumentElement","isNumberElement","isDateElement","isTimeElement","isSelectElement","isPluralElement","isTagElement","isSelectElement","isPluralElement","isPoundElement","isTagElement","candidate","variableDeclarator","parameter","objectLiteralExpression","instantiationExpressionType","declaration","node","exportDecl","decl","heritageClause","unaryWordExpression","includeOriginalSymbolOfBindingElement","varStatement","testTypeOrder","stringify","stringifyNs","format","compile","format","compile","format","compile","format","compile","format","compile","format","defaultFormatter","transifex","smartling","simple","lokalise","crowdin","ts","stringifyNs","extractKeys","debug","glob","extract","compile","cli"],"sources":["../../../node_modules/.aspect_rules_js/commander@14.0.3/node_modules/commander/lib/error.js","../../../node_modules/.aspect_rules_js/commander@14.0.3/node_modules/commander/lib/argument.js","../../../node_modules/.aspect_rules_js/commander@14.0.3/node_modules/commander/lib/help.js","../../../node_modules/.aspect_rules_js/commander@14.0.3/node_modules/commander/lib/option.js","../../../node_modules/.aspect_rules_js/commander@14.0.3/node_modules/commander/lib/suggestSimilar.js","../../../node_modules/.aspect_rules_js/commander@14.0.3/node_modules/commander/lib/command.js","../../../node_modules/.aspect_rules_js/commander@14.0.3/node_modules/commander/index.js","../../../node_modules/.aspect_rules_js/commander@14.0.3/node_modules/commander/esm.mjs","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/utils/array.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/utils/errno.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/utils/fs.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/utils/path.js","../../../node_modules/.aspect_rules_js/is-extglob@2.1.1/node_modules/is-extglob/index.js","../../../node_modules/.aspect_rules_js/is-glob@4.0.3/node_modules/is-glob/index.js","../../../node_modules/.aspect_rules_js/glob-parent@5.1.2/node_modules/glob-parent/index.js","../../../node_modules/.aspect_rules_js/braces@3.0.3/node_modules/braces/lib/utils.js","../../../node_modules/.aspect_rules_js/braces@3.0.3/node_modules/braces/lib/stringify.js","../../../node_modules/.aspect_rules_js/is-number@7.0.0/node_modules/is-number/index.js","../../../node_modules/.aspect_rules_js/to-regex-range@5.0.1/node_modules/to-regex-range/index.js","../../../node_modules/.aspect_rules_js/fill-range@7.1.1/node_modules/fill-range/index.js","../../../node_modules/.aspect_rules_js/braces@3.0.3/node_modules/braces/lib/compile.js","../../../node_modules/.aspect_rules_js/braces@3.0.3/node_modules/braces/lib/expand.js","../../../node_modules/.aspect_rules_js/braces@3.0.3/node_modules/braces/lib/constants.js","../../../node_modules/.aspect_rules_js/braces@3.0.3/node_modules/braces/lib/parse.js","../../../node_modules/.aspect_rules_js/braces@3.0.3/node_modules/braces/index.js","../../../node_modules/.aspect_rules_js/picomatch@2.3.2/node_modules/picomatch/lib/constants.js","../../../node_modules/.aspect_rules_js/picomatch@2.3.2/node_modules/picomatch/lib/utils.js","../../../node_modules/.aspect_rules_js/picomatch@2.3.2/node_modules/picomatch/lib/scan.js","../../../node_modules/.aspect_rules_js/picomatch@2.3.2/node_modules/picomatch/lib/parse.js","../../../node_modules/.aspect_rules_js/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js","../../../node_modules/.aspect_rules_js/picomatch@2.3.2/node_modules/picomatch/index.js","../../../node_modules/.aspect_rules_js/micromatch@4.0.8/node_modules/micromatch/index.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/utils/pattern.js","../../../node_modules/.aspect_rules_js/merge2@1.4.1/node_modules/merge2/index.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/utils/stream.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/utils/string.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/utils/index.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/managers/tasks.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/providers/async.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/providers/sync.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/adapters/fs.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/settings.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/index.js","../../../node_modules/.aspect_rules_js/queue-microtask@1.2.3/node_modules/queue-microtask/index.js","../../../node_modules/.aspect_rules_js/run-parallel@1.2.0/node_modules/run-parallel/index.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/constants.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/utils/fs.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/utils/index.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/providers/common.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/providers/async.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/providers/sync.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/adapters/fs.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/settings.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/index.js","../../../node_modules/.aspect_rules_js/reusify@1.1.0/node_modules/reusify/reusify.js","../../../node_modules/.aspect_rules_js/fastq@1.20.1/node_modules/fastq/queue.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/readers/common.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/readers/reader.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/readers/async.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/providers/async.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/providers/stream.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/readers/sync.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/providers/sync.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/settings.js","../../../node_modules/.aspect_rules_js/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/index.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/readers/reader.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/readers/stream.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/readers/async.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/providers/matchers/matcher.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/providers/matchers/partial.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/providers/filters/deep.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/providers/filters/entry.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/providers/filters/error.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/providers/transformers/entry.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/providers/provider.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/providers/async.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/providers/stream.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/readers/sync.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/providers/sync.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/settings.js","../../../node_modules/.aspect_rules_js/fast-glob@3.3.3/node_modules/fast-glob/out/index.js","../../../node_modules/.aspect_rules_js/signal-exit@3.0.7/node_modules/signal-exit/signals.js","../../../node_modules/.aspect_rules_js/signal-exit@3.0.7/node_modules/signal-exit/index.js","../../../node_modules/.aspect_rules_js/array-find-index@1.0.2/node_modules/array-find-index/index.js","../../../node_modules/.aspect_rules_js/currently-unhandled@0.4.1/node_modules/currently-unhandled/core.js","../../../node_modules/.aspect_rules_js/currently-unhandled@0.4.1/node_modules/currently-unhandled/index.js","../../../node_modules/.aspect_rules_js/loud-rejection@2.2.0/node_modules/loud-rejection/index.js","../../../node_modules/.aspect_rules_js/universalify@2.0.1/node_modules/universalify/index.js","../../../node_modules/.aspect_rules_js/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js","../../../node_modules/.aspect_rules_js/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js","../../../node_modules/.aspect_rules_js/graceful-fs@4.2.11/node_modules/graceful-fs/clone.js","../../../node_modules/.aspect_rules_js/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/fs/index.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/mkdirs/utils.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/mkdirs/make-dir.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/mkdirs/index.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/path-exists/index.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/util/utimes.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/util/stat.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/util/async.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/copy/copy.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/copy/copy-sync.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/copy/index.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/remove/index.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/empty/index.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/ensure/file.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/ensure/link.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/ensure/symlink-paths.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/ensure/symlink-type.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/ensure/symlink.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/ensure/index.js","../../../node_modules/.aspect_rules_js/jsonfile@6.2.1/node_modules/jsonfile/utils.js","../../../node_modules/.aspect_rules_js/jsonfile@6.2.1/node_modules/jsonfile/index.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/json/jsonfile.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/output-file/index.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/json/output-json.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/json/output-json-sync.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/json/index.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/move/move.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/move/move-sync.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/move/index.js","../../../node_modules/.aspect_rules_js/fs-extra@11.3.5/node_modules/fs-extra/lib/esm.mjs","../../../node_modules/.aspect_rules_js/jsonify@0.0.1/node_modules/jsonify/lib/parse.js","../../../node_modules/.aspect_rules_js/jsonify@0.0.1/node_modules/jsonify/lib/stringify.js","../../../node_modules/.aspect_rules_js/jsonify@0.0.1/node_modules/jsonify/index.js","../../../node_modules/.aspect_rules_js/isarray@2.0.5/node_modules/isarray/index.js","../../../node_modules/.aspect_rules_js/object-keys@1.1.1/node_modules/object-keys/isArguments.js","../../../node_modules/.aspect_rules_js/object-keys@1.1.1/node_modules/object-keys/implementation.js","../../../node_modules/.aspect_rules_js/object-keys@1.1.1/node_modules/object-keys/index.js","../../../node_modules/.aspect_rules_js/es-object-atoms@1.1.1/node_modules/es-object-atoms/index.js","../../../node_modules/.aspect_rules_js/es-errors@1.3.0/node_modules/es-errors/index.js","../../../node_modules/.aspect_rules_js/es-errors@1.3.0/node_modules/es-errors/eval.js","../../../node_modules/.aspect_rules_js/es-errors@1.3.0/node_modules/es-errors/range.js","../../../node_modules/.aspect_rules_js/es-errors@1.3.0/node_modules/es-errors/ref.js","../../../node_modules/.aspect_rules_js/es-errors@1.3.0/node_modules/es-errors/syntax.js","../../../node_modules/.aspect_rules_js/es-errors@1.3.0/node_modules/es-errors/type.js","../../../node_modules/.aspect_rules_js/es-errors@1.3.0/node_modules/es-errors/uri.js","../../../node_modules/.aspect_rules_js/math-intrinsics@1.1.0/node_modules/math-intrinsics/abs.js","../../../node_modules/.aspect_rules_js/math-intrinsics@1.1.0/node_modules/math-intrinsics/floor.js","../../../node_modules/.aspect_rules_js/math-intrinsics@1.1.0/node_modules/math-intrinsics/max.js","../../../node_modules/.aspect_rules_js/math-intrinsics@1.1.0/node_modules/math-intrinsics/min.js","../../../node_modules/.aspect_rules_js/math-intrinsics@1.1.0/node_modules/math-intrinsics/pow.js","../../../node_modules/.aspect_rules_js/math-intrinsics@1.1.0/node_modules/math-intrinsics/round.js","../../../node_modules/.aspect_rules_js/math-intrinsics@1.1.0/node_modules/math-intrinsics/isNaN.js","../../../node_modules/.aspect_rules_js/math-intrinsics@1.1.0/node_modules/math-intrinsics/sign.js","../../../node_modules/.aspect_rules_js/gopd@1.2.0/node_modules/gopd/gOPD.js","../../../node_modules/.aspect_rules_js/gopd@1.2.0/node_modules/gopd/index.js","../../../node_modules/.aspect_rules_js/es-define-property@1.0.1/node_modules/es-define-property/index.js","../../../node_modules/.aspect_rules_js/has-symbols@1.1.0/node_modules/has-symbols/shams.js","../../../node_modules/.aspect_rules_js/has-symbols@1.1.0/node_modules/has-symbols/index.js","../../../node_modules/.aspect_rules_js/get-proto@1.0.1/node_modules/get-proto/Reflect.getPrototypeOf.js","../../../node_modules/.aspect_rules_js/get-proto@1.0.1/node_modules/get-proto/Object.getPrototypeOf.js","../../../node_modules/.aspect_rules_js/function-bind@1.1.2/node_modules/function-bind/implementation.js","../../../node_modules/.aspect_rules_js/function-bind@1.1.2/node_modules/function-bind/index.js","../../../node_modules/.aspect_rules_js/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/functionCall.js","../../../node_modules/.aspect_rules_js/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/functionApply.js","../../../node_modules/.aspect_rules_js/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/reflectApply.js","../../../node_modules/.aspect_rules_js/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/actualApply.js","../../../node_modules/.aspect_rules_js/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/index.js","../../../node_modules/.aspect_rules_js/dunder-proto@1.0.1/node_modules/dunder-proto/get.js","../../../node_modules/.aspect_rules_js/get-proto@1.0.1/node_modules/get-proto/index.js","../../../node_modules/.aspect_rules_js/hasown@2.0.2/node_modules/hasown/index.js","../../../node_modules/.aspect_rules_js/get-intrinsic@1.3.0/node_modules/get-intrinsic/index.js","../../../node_modules/.aspect_rules_js/define-data-property@1.1.4/node_modules/define-data-property/index.js","../../../node_modules/.aspect_rules_js/has-property-descriptors@1.0.2/node_modules/has-property-descriptors/index.js","../../../node_modules/.aspect_rules_js/set-function-length@1.2.2/node_modules/set-function-length/index.js","../../../node_modules/.aspect_rules_js/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/applyBind.js","../../../node_modules/.aspect_rules_js/call-bind@1.0.8/node_modules/call-bind/index.js","../../../node_modules/.aspect_rules_js/call-bound@1.0.4/node_modules/call-bound/index.js","../../../node_modules/.aspect_rules_js/json-stable-stringify@1.3.0/node_modules/json-stable-stringify/index.js","../console_utils.ts","../native.ts","../compile.ts","../compile_folder.ts","../../../node_modules/.aspect_rules_js/@formatjs+icu-skeleton-parser@0.0.0/node_modules/@formatjs/icu-skeleton-parser/index.js","../../../node_modules/.aspect_rules_js/@formatjs+icu-messageformat-parser@0.0.0/node_modules/@formatjs/icu-messageformat-parser/index.js","../../../node_modules/.aspect_rules_js/@formatjs+icu-messageformat-parser@0.0.0/node_modules/@formatjs/icu-messageformat-parser/manipulator.js","../../../node_modules/.aspect_rules_js/@formatjs+icu-messageformat-parser@0.0.0/node_modules/@formatjs/icu-messageformat-parser/printer.js","../../../node_modules/.aspect_rules_js/typescript@6.0.3/node_modules/typescript/lib/typescript.js","../../../node_modules/.aspect_rules_js/@formatjs+ts-transformer@0.0.0/node_modules/@formatjs/ts-transformer/index.js","../formatters/crowdin.ts","../formatters/default.ts","../formatters/lokalise.ts","../formatters/simple.ts","../formatters/smartling.ts","../formatters/transifex.ts","../formatters/index.ts","../parse_script.ts","../extract.ts","../verify/checkMissingKeys.ts","../verify/checkExtraKeys.ts","../verify/checkStructuralEquality.ts","../verify/index.ts","../cli.ts","../main.ts"],"sourcesContent":["/**\n * CommanderError class\n */\nclass CommanderError extends Error {\n /**\n * Constructs the CommanderError class\n * @param {number} exitCode suggested exit code which could be used with process.exit\n * @param {string} code an id string representing the error\n * @param {string} message human-readable description of the error\n */\n constructor(exitCode, code, message) {\n super(message);\n // properly capture stack trace in Node.js\n Error.captureStackTrace(this, this.constructor);\n this.name = this.constructor.name;\n this.code = code;\n this.exitCode = exitCode;\n this.nestedError = undefined;\n }\n}\n\n/**\n * InvalidArgumentError class\n */\nclass InvalidArgumentError extends CommanderError {\n /**\n * Constructs the InvalidArgumentError class\n * @param {string} [message] explanation of why argument is invalid\n */\n constructor(message) {\n super(1, 'commander.invalidArgument', message);\n // properly capture stack trace in Node.js\n Error.captureStackTrace(this, this.constructor);\n this.name = this.constructor.name;\n }\n}\n\nexports.CommanderError = CommanderError;\nexports.InvalidArgumentError = InvalidArgumentError;\n","const { InvalidArgumentError } = require('./error.js');\n\nclass Argument {\n /**\n * Initialize a new command argument with the given name and description.\n * The default is that the argument is required, and you can explicitly\n * indicate this with <> around the name. Put [] around the name for an optional argument.\n *\n * @param {string} name\n * @param {string} [description]\n */\n\n constructor(name, description) {\n this.description = description || '';\n this.variadic = false;\n this.parseArg = undefined;\n this.defaultValue = undefined;\n this.defaultValueDescription = undefined;\n this.argChoices = undefined;\n\n switch (name[0]) {\n case '<': // e.g. <required>\n this.required = true;\n this._name = name.slice(1, -1);\n break;\n case '[': // e.g. [optional]\n this.required = false;\n this._name = name.slice(1, -1);\n break;\n default:\n this.required = true;\n this._name = name;\n break;\n }\n\n if (this._name.endsWith('...')) {\n this.variadic = true;\n this._name = this._name.slice(0, -3);\n }\n }\n\n /**\n * Return argument name.\n *\n * @return {string}\n */\n\n name() {\n return this._name;\n }\n\n /**\n * @package\n */\n\n _collectValue(value, previous) {\n if (previous === this.defaultValue || !Array.isArray(previous)) {\n return [value];\n }\n\n previous.push(value);\n return previous;\n }\n\n /**\n * Set the default value, and optionally supply the description to be displayed in the help.\n *\n * @param {*} value\n * @param {string} [description]\n * @return {Argument}\n */\n\n default(value, description) {\n this.defaultValue = value;\n this.defaultValueDescription = description;\n return this;\n }\n\n /**\n * Set the custom handler for processing CLI command arguments into argument values.\n *\n * @param {Function} [fn]\n * @return {Argument}\n */\n\n argParser(fn) {\n this.parseArg = fn;\n return this;\n }\n\n /**\n * Only allow argument value to be one of choices.\n *\n * @param {string[]} values\n * @return {Argument}\n */\n\n choices(values) {\n this.argChoices = values.slice();\n this.parseArg = (arg, previous) => {\n if (!this.argChoices.includes(arg)) {\n throw new InvalidArgumentError(\n `Allowed choices are ${this.argChoices.join(', ')}.`,\n );\n }\n if (this.variadic) {\n return this._collectValue(arg, previous);\n }\n return arg;\n };\n return this;\n }\n\n /**\n * Make argument required.\n *\n * @returns {Argument}\n */\n argRequired() {\n this.required = true;\n return this;\n }\n\n /**\n * Make argument optional.\n *\n * @returns {Argument}\n */\n argOptional() {\n this.required = false;\n return this;\n }\n}\n\n/**\n * Takes an argument and returns its human readable equivalent for help usage.\n *\n * @param {Argument} arg\n * @return {string}\n * @private\n */\n\nfunction humanReadableArgName(arg) {\n const nameOutput = arg.name() + (arg.variadic === true ? '...' : '');\n\n return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']';\n}\n\nexports.Argument = Argument;\nexports.humanReadableArgName = humanReadableArgName;\n","const { humanReadableArgName } = require('./argument.js');\n\n/**\n * TypeScript import types for JSDoc, used by Visual Studio Code IntelliSense and `npm run typescript-checkJS`\n * https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#import-types\n * @typedef { import(\"./argument.js\").Argument } Argument\n * @typedef { import(\"./command.js\").Command } Command\n * @typedef { import(\"./option.js\").Option } Option\n */\n\n// Although this is a class, methods are static in style to allow override using subclass or just functions.\nclass Help {\n constructor() {\n this.helpWidth = undefined;\n this.minWidthToWrap = 40;\n this.sortSubcommands = false;\n this.sortOptions = false;\n this.showGlobalOptions = false;\n }\n\n /**\n * prepareContext is called by Commander after applying overrides from `Command.configureHelp()`\n * and just before calling `formatHelp()`.\n *\n * Commander just uses the helpWidth and the rest is provided for optional use by more complex subclasses.\n *\n * @param {{ error?: boolean, helpWidth?: number, outputHasColors?: boolean }} contextOptions\n */\n prepareContext(contextOptions) {\n this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;\n }\n\n /**\n * Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.\n *\n * @param {Command} cmd\n * @returns {Command[]}\n */\n\n visibleCommands(cmd) {\n const visibleCommands = cmd.commands.filter((cmd) => !cmd._hidden);\n const helpCommand = cmd._getHelpCommand();\n if (helpCommand && !helpCommand._hidden) {\n visibleCommands.push(helpCommand);\n }\n if (this.sortSubcommands) {\n visibleCommands.sort((a, b) => {\n // @ts-ignore: because overloaded return type\n return a.name().localeCompare(b.name());\n });\n }\n return visibleCommands;\n }\n\n /**\n * Compare options for sort.\n *\n * @param {Option} a\n * @param {Option} b\n * @returns {number}\n */\n compareOptions(a, b) {\n const getSortKey = (option) => {\n // WYSIWYG for order displayed in help. Short used for comparison if present. No special handling for negated.\n return option.short\n ? option.short.replace(/^-/, '')\n : option.long.replace(/^--/, '');\n };\n return getSortKey(a).localeCompare(getSortKey(b));\n }\n\n /**\n * Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.\n *\n * @param {Command} cmd\n * @returns {Option[]}\n */\n\n visibleOptions(cmd) {\n const visibleOptions = cmd.options.filter((option) => !option.hidden);\n // Built-in help option.\n const helpOption = cmd._getHelpOption();\n if (helpOption && !helpOption.hidden) {\n // Automatically hide conflicting flags. Bit dubious but a historical behaviour that is convenient for single-command programs.\n const removeShort = helpOption.short && cmd._findOption(helpOption.short);\n const removeLong = helpOption.long && cmd._findOption(helpOption.long);\n if (!removeShort && !removeLong) {\n visibleOptions.push(helpOption); // no changes needed\n } else if (helpOption.long && !removeLong) {\n visibleOptions.push(\n cmd.createOption(helpOption.long, helpOption.description),\n );\n } else if (helpOption.short && !removeShort) {\n visibleOptions.push(\n cmd.createOption(helpOption.short, helpOption.description),\n );\n }\n }\n if (this.sortOptions) {\n visibleOptions.sort(this.compareOptions);\n }\n return visibleOptions;\n }\n\n /**\n * Get an array of the visible global options. (Not including help.)\n *\n * @param {Command} cmd\n * @returns {Option[]}\n */\n\n visibleGlobalOptions(cmd) {\n if (!this.showGlobalOptions) return [];\n\n const globalOptions = [];\n for (\n let ancestorCmd = cmd.parent;\n ancestorCmd;\n ancestorCmd = ancestorCmd.parent\n ) {\n const visibleOptions = ancestorCmd.options.filter(\n (option) => !option.hidden,\n );\n globalOptions.push(...visibleOptions);\n }\n if (this.sortOptions) {\n globalOptions.sort(this.compareOptions);\n }\n return globalOptions;\n }\n\n /**\n * Get an array of the arguments if any have a description.\n *\n * @param {Command} cmd\n * @returns {Argument[]}\n */\n\n visibleArguments(cmd) {\n // Side effect! Apply the legacy descriptions before the arguments are displayed.\n if (cmd._argsDescription) {\n cmd.registeredArguments.forEach((argument) => {\n argument.description =\n argument.description || cmd._argsDescription[argument.name()] || '';\n });\n }\n\n // If there are any arguments with a description then return all the arguments.\n if (cmd.registeredArguments.find((argument) => argument.description)) {\n return cmd.registeredArguments;\n }\n return [];\n }\n\n /**\n * Get the command term to show in the list of subcommands.\n *\n * @param {Command} cmd\n * @returns {string}\n */\n\n subcommandTerm(cmd) {\n // Legacy. Ignores custom usage string, and nested commands.\n const args = cmd.registeredArguments\n .map((arg) => humanReadableArgName(arg))\n .join(' ');\n return (\n cmd._name +\n (cmd._aliases[0] ? '|' + cmd._aliases[0] : '') +\n (cmd.options.length ? ' [options]' : '') + // simplistic check for non-help option\n (args ? ' ' + args : '')\n );\n }\n\n /**\n * Get the option term to show in the list of options.\n *\n * @param {Option} option\n * @returns {string}\n */\n\n optionTerm(option) {\n return option.flags;\n }\n\n /**\n * Get the argument term to show in the list of arguments.\n *\n * @param {Argument} argument\n * @returns {string}\n */\n\n argumentTerm(argument) {\n return argument.name();\n }\n\n /**\n * Get the longest command term length.\n *\n * @param {Command} cmd\n * @param {Help} helper\n * @returns {number}\n */\n\n longestSubcommandTermLength(cmd, helper) {\n return helper.visibleCommands(cmd).reduce((max, command) => {\n return Math.max(\n max,\n this.displayWidth(\n helper.styleSubcommandTerm(helper.subcommandTerm(command)),\n ),\n );\n }, 0);\n }\n\n /**\n * Get the longest option term length.\n *\n * @param {Command} cmd\n * @param {Help} helper\n * @returns {number}\n */\n\n longestOptionTermLength(cmd, helper) {\n return helper.visibleOptions(cmd).reduce((max, option) => {\n return Math.max(\n max,\n this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))),\n );\n }, 0);\n }\n\n /**\n * Get the longest global option term length.\n *\n * @param {Command} cmd\n * @param {Help} helper\n * @returns {number}\n */\n\n longestGlobalOptionTermLength(cmd, helper) {\n return helper.visibleGlobalOptions(cmd).reduce((max, option) => {\n return Math.max(\n max,\n this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))),\n );\n }, 0);\n }\n\n /**\n * Get the longest argument term length.\n *\n * @param {Command} cmd\n * @param {Help} helper\n * @returns {number}\n */\n\n longestArgumentTermLength(cmd, helper) {\n return helper.visibleArguments(cmd).reduce((max, argument) => {\n return Math.max(\n max,\n this.displayWidth(\n helper.styleArgumentTerm(helper.argumentTerm(argument)),\n ),\n );\n }, 0);\n }\n\n /**\n * Get the command usage to be displayed at the top of the built-in help.\n *\n * @param {Command} cmd\n * @returns {string}\n */\n\n commandUsage(cmd) {\n // Usage\n let cmdName = cmd._name;\n if (cmd._aliases[0]) {\n cmdName = cmdName + '|' + cmd._aliases[0];\n }\n let ancestorCmdNames = '';\n for (\n let ancestorCmd = cmd.parent;\n ancestorCmd;\n ancestorCmd = ancestorCmd.parent\n ) {\n ancestorCmdNames = ancestorCmd.name() + ' ' + ancestorCmdNames;\n }\n return ancestorCmdNames + cmdName + ' ' + cmd.usage();\n }\n\n /**\n * Get the description for the command.\n *\n * @param {Command} cmd\n * @returns {string}\n */\n\n commandDescription(cmd) {\n // @ts-ignore: because overloaded return type\n return cmd.description();\n }\n\n /**\n * Get the subcommand summary to show in the list of subcommands.\n * (Fallback to description for backwards compatibility.)\n *\n * @param {Command} cmd\n * @returns {string}\n */\n\n subcommandDescription(cmd) {\n // @ts-ignore: because overloaded return type\n return cmd.summary() || cmd.description();\n }\n\n /**\n * Get the option description to show in the list of options.\n *\n * @param {Option} option\n * @return {string}\n */\n\n optionDescription(option) {\n const extraInfo = [];\n\n if (option.argChoices) {\n extraInfo.push(\n // use stringify to match the display of the default value\n `choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`,\n );\n }\n if (option.defaultValue !== undefined) {\n // default for boolean and negated more for programmer than end user,\n // but show true/false for boolean option as may be for hand-rolled env or config processing.\n const showDefault =\n option.required ||\n option.optional ||\n (option.isBoolean() && typeof option.defaultValue === 'boolean');\n if (showDefault) {\n extraInfo.push(\n `default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`,\n );\n }\n }\n // preset for boolean and negated are more for programmer than end user\n if (option.presetArg !== undefined && option.optional) {\n extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);\n }\n if (option.envVar !== undefined) {\n extraInfo.push(`env: ${option.envVar}`);\n }\n if (extraInfo.length > 0) {\n const extraDescription = `(${extraInfo.join(', ')})`;\n if (option.description) {\n return `${option.description} ${extraDescription}`;\n }\n return extraDescription;\n }\n\n return option.description;\n }\n\n /**\n * Get the argument description to show in the list of arguments.\n *\n * @param {Argument} argument\n * @return {string}\n */\n\n argumentDescription(argument) {\n const extraInfo = [];\n if (argument.argChoices) {\n extraInfo.push(\n // use stringify to match the display of the default value\n `choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`,\n );\n }\n if (argument.defaultValue !== undefined) {\n extraInfo.push(\n `default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`,\n );\n }\n if (extraInfo.length > 0) {\n const extraDescription = `(${extraInfo.join(', ')})`;\n if (argument.description) {\n return `${argument.description} ${extraDescription}`;\n }\n return extraDescription;\n }\n return argument.description;\n }\n\n /**\n * Format a list of items, given a heading and an array of formatted items.\n *\n * @param {string} heading\n * @param {string[]} items\n * @param {Help} helper\n * @returns string[]\n */\n formatItemList(heading, items, helper) {\n if (items.length === 0) return [];\n\n return [helper.styleTitle(heading), ...items, ''];\n }\n\n /**\n * Group items by their help group heading.\n *\n * @param {Command[] | Option[]} unsortedItems\n * @param {Command[] | Option[]} visibleItems\n * @param {Function} getGroup\n * @returns {Map<string, Command[] | Option[]>}\n */\n groupItems(unsortedItems, visibleItems, getGroup) {\n const result = new Map();\n // Add groups in order of appearance in unsortedItems.\n unsortedItems.forEach((item) => {\n const group = getGroup(item);\n if (!result.has(group)) result.set(group, []);\n });\n // Add items in order of appearance in visibleItems.\n visibleItems.forEach((item) => {\n const group = getGroup(item);\n if (!result.has(group)) {\n result.set(group, []);\n }\n result.get(group).push(item);\n });\n return result;\n }\n\n /**\n * Generate the built-in help text.\n *\n * @param {Command} cmd\n * @param {Help} helper\n * @returns {string}\n */\n\n formatHelp(cmd, helper) {\n const termWidth = helper.padWidth(cmd, helper);\n const helpWidth = helper.helpWidth ?? 80; // in case prepareContext() was not called\n\n function callFormatItem(term, description) {\n return helper.formatItem(term, termWidth, description, helper);\n }\n\n // Usage\n let output = [\n `${helper.styleTitle('Usage:')} ${helper.styleUsage(helper.commandUsage(cmd))}`,\n '',\n ];\n\n // Description\n const commandDescription = helper.commandDescription(cmd);\n if (commandDescription.length > 0) {\n output = output.concat([\n helper.boxWrap(\n helper.styleCommandDescription(commandDescription),\n helpWidth,\n ),\n '',\n ]);\n }\n\n // Arguments\n const argumentList = helper.visibleArguments(cmd).map((argument) => {\n return callFormatItem(\n helper.styleArgumentTerm(helper.argumentTerm(argument)),\n helper.styleArgumentDescription(helper.argumentDescription(argument)),\n );\n });\n output = output.concat(\n this.formatItemList('Arguments:', argumentList, helper),\n );\n\n // Options\n const optionGroups = this.groupItems(\n cmd.options,\n helper.visibleOptions(cmd),\n (option) => option.helpGroupHeading ?? 'Options:',\n );\n optionGroups.forEach((options, group) => {\n const optionList = options.map((option) => {\n return callFormatItem(\n helper.styleOptionTerm(helper.optionTerm(option)),\n helper.styleOptionDescription(helper.optionDescription(option)),\n );\n });\n output = output.concat(this.formatItemList(group, optionList, helper));\n });\n\n if (helper.showGlobalOptions) {\n const globalOptionList = helper\n .visibleGlobalOptions(cmd)\n .map((option) => {\n return callFormatItem(\n helper.styleOptionTerm(helper.optionTerm(option)),\n helper.styleOptionDescription(helper.optionDescription(option)),\n );\n });\n output = output.concat(\n this.formatItemList('Global Options:', globalOptionList, helper),\n );\n }\n\n // Commands\n const commandGroups = this.groupItems(\n cmd.commands,\n helper.visibleCommands(cmd),\n (sub) => sub.helpGroup() || 'Commands:',\n );\n commandGroups.forEach((commands, group) => {\n const commandList = commands.map((sub) => {\n return callFormatItem(\n helper.styleSubcommandTerm(helper.subcommandTerm(sub)),\n helper.styleSubcommandDescription(helper.subcommandDescription(sub)),\n );\n });\n output = output.concat(this.formatItemList(group, commandList, helper));\n });\n\n return output.join('\\n');\n }\n\n /**\n * Return display width of string, ignoring ANSI escape sequences. Used in padding and wrapping calculations.\n *\n * @param {string} str\n * @returns {number}\n */\n displayWidth(str) {\n return stripColor(str).length;\n }\n\n /**\n * Style the title for displaying in the help. Called with 'Usage:', 'Options:', etc.\n *\n * @param {string} str\n * @returns {string}\n */\n styleTitle(str) {\n return str;\n }\n\n styleUsage(str) {\n // Usage has lots of parts the user might like to color separately! Assume default usage string which is formed like:\n // command subcommand [options] [command] <foo> [bar]\n return str\n .split(' ')\n .map((word) => {\n if (word === '[options]') return this.styleOptionText(word);\n if (word === '[command]') return this.styleSubcommandText(word);\n if (word[0] === '[' || word[0] === '<')\n return this.styleArgumentText(word);\n return this.styleCommandText(word); // Restrict to initial words?\n })\n .join(' ');\n }\n styleCommandDescription(str) {\n return this.styleDescriptionText(str);\n }\n styleOptionDescription(str) {\n return this.styleDescriptionText(str);\n }\n styleSubcommandDescription(str) {\n return this.styleDescriptionText(str);\n }\n styleArgumentDescription(str) {\n return this.styleDescriptionText(str);\n }\n styleDescriptionText(str) {\n return str;\n }\n styleOptionTerm(str) {\n return this.styleOptionText(str);\n }\n styleSubcommandTerm(str) {\n // This is very like usage with lots of parts! Assume default string which is formed like:\n // subcommand [options] <foo> [bar]\n return str\n .split(' ')\n .map((word) => {\n if (word === '[options]') return this.styleOptionText(word);\n if (word[0] === '[' || word[0] === '<')\n return this.styleArgumentText(word);\n return this.styleSubcommandText(word); // Restrict to initial words?\n })\n .join(' ');\n }\n styleArgumentTerm(str) {\n return this.styleArgumentText(str);\n }\n styleOptionText(str) {\n return str;\n }\n styleArgumentText(str) {\n return str;\n }\n styleSubcommandText(str) {\n return str;\n }\n styleCommandText(str) {\n return str;\n }\n\n /**\n * Calculate the pad width from the maximum term length.\n *\n * @param {Command} cmd\n * @param {Help} helper\n * @returns {number}\n */\n\n padWidth(cmd, helper) {\n return Math.max(\n helper.longestOptionTermLength(cmd, helper),\n helper.longestGlobalOptionTermLength(cmd, helper),\n helper.longestSubcommandTermLength(cmd, helper),\n helper.longestArgumentTermLength(cmd, helper),\n );\n }\n\n /**\n * Detect manually wrapped and indented strings by checking for line break followed by whitespace.\n *\n * @param {string} str\n * @returns {boolean}\n */\n preformatted(str) {\n return /\\n[^\\S\\r\\n]/.test(str);\n }\n\n /**\n * Format the \"item\", which consists of a term and description. Pad the term and wrap the description, indenting the following lines.\n *\n * So \"TTT\", 5, \"DDD DDDD DD DDD\" might be formatted for this.helpWidth=17 like so:\n * TTT DDD DDDD\n * DD DDD\n *\n * @param {string} term\n * @param {number} termWidth\n * @param {string} description\n * @param {Help} helper\n * @returns {string}\n */\n formatItem(term, termWidth, description, helper) {\n const itemIndent = 2;\n const itemIndentStr = ' '.repeat(itemIndent);\n if (!description) return itemIndentStr + term;\n\n // Pad the term out to a consistent width, so descriptions are aligned.\n const paddedTerm = term.padEnd(\n termWidth + term.length - helper.displayWidth(term),\n );\n\n // Format the description.\n const spacerWidth = 2; // between term and description\n const helpWidth = this.helpWidth ?? 80; // in case prepareContext() was not called\n const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;\n let formattedDescription;\n if (\n remainingWidth < this.minWidthToWrap ||\n helper.preformatted(description)\n ) {\n formattedDescription = description;\n } else {\n const wrappedDescription = helper.boxWrap(description, remainingWidth);\n formattedDescription = wrappedDescription.replace(\n /\\n/g,\n '\\n' + ' '.repeat(termWidth + spacerWidth),\n );\n }\n\n // Construct and overall indent.\n return (\n itemIndentStr +\n paddedTerm +\n ' '.repeat(spacerWidth) +\n formattedDescription.replace(/\\n/g, `\\n${itemIndentStr}`)\n );\n }\n\n /**\n * Wrap a string at whitespace, preserving existing line breaks.\n * Wrapping is skipped if the width is less than `minWidthToWrap`.\n *\n * @param {string} str\n * @param {number} width\n * @returns {string}\n */\n boxWrap(str, width) {\n if (width < this.minWidthToWrap) return str;\n\n const rawLines = str.split(/\\r\\n|\\n/);\n // split up text by whitespace\n const chunkPattern = /[\\s]*[^\\s]+/g;\n const wrappedLines = [];\n rawLines.forEach((line) => {\n const chunks = line.match(chunkPattern);\n if (chunks === null) {\n wrappedLines.push('');\n return;\n }\n\n let sumChunks = [chunks.shift()];\n let sumWidth = this.displayWidth(sumChunks[0]);\n chunks.forEach((chunk) => {\n const visibleWidth = this.displayWidth(chunk);\n // Accumulate chunks while they fit into width.\n if (sumWidth + visibleWidth <= width) {\n sumChunks.push(chunk);\n sumWidth += visibleWidth;\n return;\n }\n wrappedLines.push(sumChunks.join(''));\n\n const nextChunk = chunk.trimStart(); // trim space at line break\n sumChunks = [nextChunk];\n sumWidth = this.displayWidth(nextChunk);\n });\n wrappedLines.push(sumChunks.join(''));\n });\n\n return wrappedLines.join('\\n');\n }\n}\n\n/**\n * Strip style ANSI escape sequences from the string. In particular, SGR (Select Graphic Rendition) codes.\n *\n * @param {string} str\n * @returns {string}\n * @package\n */\n\nfunction stripColor(str) {\n // eslint-disable-next-line no-control-regex\n const sgrPattern = /\\x1b\\[\\d*(;\\d*)*m/g;\n return str.replace(sgrPattern, '');\n}\n\nexports.Help = Help;\nexports.stripColor = stripColor;\n","const { InvalidArgumentError } = require('./error.js');\n\nclass Option {\n /**\n * Initialize a new `Option` with the given `flags` and `description`.\n *\n * @param {string} flags\n * @param {string} [description]\n */\n\n constructor(flags, description) {\n this.flags = flags;\n this.description = description || '';\n\n this.required = flags.includes('<'); // A value must be supplied when the option is specified.\n this.optional = flags.includes('['); // A value is optional when the option is specified.\n // variadic test ignores <value,...> et al which might be used to describe custom splitting of single argument\n this.variadic = /\\w\\.\\.\\.[>\\]]$/.test(flags); // The option can take multiple values.\n this.mandatory = false; // The option must have a value after parsing, which usually means it must be specified on command line.\n const optionFlags = splitOptionFlags(flags);\n this.short = optionFlags.shortFlag; // May be a short flag, undefined, or even a long flag (if option has two long flags).\n this.long = optionFlags.longFlag;\n this.negate = false;\n if (this.long) {\n this.negate = this.long.startsWith('--no-');\n }\n this.defaultValue = undefined;\n this.defaultValueDescription = undefined;\n this.presetArg = undefined;\n this.envVar = undefined;\n this.parseArg = undefined;\n this.hidden = false;\n this.argChoices = undefined;\n this.conflictsWith = [];\n this.implied = undefined;\n this.helpGroupHeading = undefined; // soft initialised when option added to command\n }\n\n /**\n * Set the default value, and optionally supply the description to be displayed in the help.\n *\n * @param {*} value\n * @param {string} [description]\n * @return {Option}\n */\n\n default(value, description) {\n this.defaultValue = value;\n this.defaultValueDescription = description;\n return this;\n }\n\n /**\n * Preset to use when option used without option-argument, especially optional but also boolean and negated.\n * The custom processing (parseArg) is called.\n *\n * @example\n * new Option('--color').default('GREYSCALE').preset('RGB');\n * new Option('--donate [amount]').preset('20').argParser(parseFloat);\n *\n * @param {*} arg\n * @return {Option}\n */\n\n preset(arg) {\n this.presetArg = arg;\n return this;\n }\n\n /**\n * Add option name(s) that conflict with this option.\n * An error will be displayed if conflicting options are found during parsing.\n *\n * @example\n * new Option('--rgb').conflicts('cmyk');\n * new Option('--js').conflicts(['ts', 'jsx']);\n *\n * @param {(string | string[])} names\n * @return {Option}\n */\n\n conflicts(names) {\n this.conflictsWith = this.conflictsWith.concat(names);\n return this;\n }\n\n /**\n * Specify implied option values for when this option is set and the implied options are not.\n *\n * The custom processing (parseArg) is not called on the implied values.\n *\n * @example\n * program\n * .addOption(new Option('--log', 'write logging information to file'))\n * .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));\n *\n * @param {object} impliedOptionValues\n * @return {Option}\n */\n implies(impliedOptionValues) {\n let newImplied = impliedOptionValues;\n if (typeof impliedOptionValues === 'string') {\n // string is not documented, but easy mistake and we can do what user probably intended.\n newImplied = { [impliedOptionValues]: true };\n }\n this.implied = Object.assign(this.implied || {}, newImplied);\n return this;\n }\n\n /**\n * Set environment variable to check for option value.\n *\n * An environment variable is only used if when processed the current option value is\n * undefined, or the source of the current value is 'de