wfinder
Version:
A local file indexing and searching tool.
2 lines • 23 kB
JavaScript
exports.id=783,exports.ids=[783],exports.modules={48783:(t,e,i)=>{const n=i(28614).EventEmitter,s=i(63129),o=i(85622),r=i(35747);class Help{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1}visibleCommands(t){const e=t.commands.filter((t=>!t._hidden));if(t._hasImplicitHelpCommand()){const i=t._helpCommandnameAndArgs.split(/ +/),n=t.createCommand(i.shift()).helpOption(!1);n.description(t._helpCommandDescription),n._parseExpectedArgs(i),e.push(n)}return this.sortSubcommands&&e.sort(((t,e)=>t.name().localeCompare(e.name()))),e}visibleOptions(t){const e=t.options.filter((t=>!t.hidden)),i=t._hasHelpOption&&t._helpShortFlag&&!t._findOption(t._helpShortFlag),n=t._hasHelpOption&&!t._findOption(t._helpLongFlag);if(i||n){let s;s=i?n?t.createOption(t._helpFlags,t._helpDescription):t.createOption(t._helpShortFlag,t._helpDescription):t.createOption(t._helpLongFlag,t._helpDescription),e.push(s)}if(this.sortOptions){const getSortKey=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");e.sort(((t,e)=>getSortKey(t).localeCompare(getSortKey(e))))}return e}visibleArguments(t){return t._argsDescription&&t._args.length?t._args.map((e=>({term:e.name,description:t._argsDescription[e.name]||""})),0):[]}subcommandTerm(t){const e=t._args.map((t=>humanReadableArgName(t))).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce(((t,i)=>Math.max(t,e.subcommandTerm(i).length)),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce(((t,i)=>Math.max(t,e.optionTerm(i).length)),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce(((t,e)=>Math.max(t,e.term.length)),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let i="";for(let e=t.parent;e;e=e.parent)i=e.name()+" "+i;return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.description()}optionDescription(t){if(t.negate)return t.description;const e=[];return t.argChoices&&e.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`),void 0!==t.defaultValue&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0?`${t.description} (${e.join(", ")})`:t.description}formatHelp(t,e){const i=e.padWidth(t,e),n=e.helpWidth||80;function formatItem(t,s){if(s){const o=`${t.padEnd(i+2)}${s}`;return e.wrap(o,n-2,i+2)}return t}function formatList(t){return t.join("\n").replace(/^/gm," ".repeat(2))}let s=[`Usage: ${e.commandUsage(t)}`,""];const o=e.commandDescription(t);o.length>0&&(s=s.concat([o,""]));const r=e.visibleArguments(t).map((t=>formatItem(t.term,t.description)));r.length>0&&(s=s.concat(["Arguments:",formatList(r),""]));const a=e.visibleOptions(t).map((t=>formatItem(e.optionTerm(t),e.optionDescription(t))));a.length>0&&(s=s.concat(["Options:",formatList(a),""]));const h=e.visibleCommands(t).map((t=>formatItem(e.subcommandTerm(t),e.subcommandDescription(t))));return h.length>0&&(s=s.concat(["Commands:",formatList(h),""])),s.join("\n")}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}wrap(t,e,i,n=40){if(t.match(/[\n]\s+/))return t;const s=e-i;if(s<n)return t;const o=t.substr(0,i),r=t.substr(i),a=" ".repeat(i),h=new RegExp(".{1,"+(s-1)+"}([\\s]|$)|[^\\s]+?([\\s]|$)","g");return o+(r.match(h)||[]).map(((t,e)=>("\n"===t.slice(-1)&&(t=t.slice(0,t.length-1)),(e>0?a:"")+t.trimRight()))).join("\n")}}class Option{constructor(t,e){this.flags=t,this.description=e||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;const i=_parseOptionFlags(t);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_concatValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?e.concat(t):[t]}choices(t){return this.argChoices=t,this.parseArg=(e,i)=>{if(!t.includes(e))throw new InvalidOptionArgumentError(`Allowed choices are ${t.join(", ")}.`);return this.variadic?this._concatValue(e,i):e},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return function camelcase(t){return t.split("-").reduce(((t,e)=>t+e[0].toUpperCase()+e.slice(1)))}(this.name().replace(/^no-/,""))}is(t){return this.short===t||this.long===t}}class CommanderError extends Error{constructor(t,e,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}}class InvalidOptionArgumentError extends CommanderError{constructor(t){super(1,"commander.invalidOptionArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}class Command extends n{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this._args=[],this.rawArgs=null,this._scriptPath=null,this._name=t||"",this._optionValues={},this._storeOptionsAsProperties=!1,this._actionResults=[],this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._outputConfiguration={writeOut:t=>process.stdout.write(t),writeErr:t=>process.stderr.write(t),getOutHelpWidth:()=>process.stdout.isTTY?process.stdout.columns:void 0,getErrHelpWidth:()=>process.stderr.isTTY?process.stderr.columns:void 0,outputError:(t,e)=>e(t)},this._hidden=!1,this._hasHelpOption=!0,this._helpFlags="-h, --help",this._helpDescription="display help for command",this._helpShortFlag="-h",this._helpLongFlag="--help",this._addImplicitHelpCommand=void 0,this._helpCommandName="help",this._helpCommandnameAndArgs="help [command]",this._helpCommandDescription="display help for command",this._helpConfiguration={}}command(t,e,i){let n=e,s=i;"object"==typeof n&&null!==n&&(s=n,n=null),s=s||{};const o=t.split(/ +/),r=this.createCommand(o.shift());return n&&(r.description(n),r._executableHandler=!0),s.isDefault&&(this._defaultCommandName=r._name),r._outputConfiguration=this._outputConfiguration,r._hidden=!(!s.noHelp&&!s.hidden),r._hasHelpOption=this._hasHelpOption,r._helpFlags=this._helpFlags,r._helpDescription=this._helpDescription,r._helpShortFlag=this._helpShortFlag,r._helpLongFlag=this._helpLongFlag,r._helpCommandName=this._helpCommandName,r._helpCommandnameAndArgs=this._helpCommandnameAndArgs,r._helpCommandDescription=this._helpCommandDescription,r._helpConfiguration=this._helpConfiguration,r._exitCallback=this._exitCallback,r._storeOptionsAsProperties=this._storeOptionsAsProperties,r._combineFlagAndOptionalValue=this._combineFlagAndOptionalValue,r._allowExcessArguments=this._allowExcessArguments,r._enablePositionalOptions=this._enablePositionalOptions,r._executableFile=s.executableFile||null,this.commands.push(r),r._parseExpectedArgs(o),r.parent=this,n?this:r}createCommand(t){return new Command(t)}createHelp(){return Object.assign(new Help,this.configureHelp())}configureHelp(t){return void 0===t?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return void 0===t?this._outputConfiguration:(Object.assign(this._outputConfiguration,t),this)}addCommand(t,e){if(!t._name)throw new Error("Command passed to .addCommand() must have a name");return function checkExplicitNames(t){t.forEach((t=>{if(t._executableHandler&&!t._executableFile)throw new Error(`Must specify executableFile for deeply nested executable: ${t.name()}`);checkExplicitNames(t.commands)}))}(t.commands),(e=e||{}).isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this.commands.push(t),t.parent=this,this}arguments(t){return this._parseExpectedArgs(t.split(/ +/))}addHelpCommand(t,e){return!1===t?this._addImplicitHelpCommand=!1:(this._addImplicitHelpCommand=!0,"string"==typeof t&&(this._helpCommandName=t.split(" ")[0],this._helpCommandnameAndArgs=t),this._helpCommandDescription=e||this._helpCommandDescription),this}_hasImplicitHelpCommand(){return void 0===this._addImplicitHelpCommand?this.commands.length&&!this._actionHandler&&!this._findCommand("help"):this._addImplicitHelpCommand}_parseExpectedArgs(t){if(t.length)return t.forEach((t=>{const e={required:!1,name:"",variadic:!1};switch(t[0]){case"<":e.required=!0,e.name=t.slice(1,-1);break;case"[":e.name=t.slice(1,-1)}e.name.length>3&&"..."===e.name.slice(-3)&&(e.variadic=!0,e.name=e.name.slice(0,-3)),e.name&&this._args.push(e)})),this._args.forEach(((t,e)=>{if(t.variadic&&e<this._args.length-1)throw new Error(`only the last argument can be variadic '${t.name}'`)})),this}exitOverride(t){return this._exitCallback=t||(t=>{if("commander.executeSubCommandAsync"!==t.code)throw t}),this}_exit(t,e,i){this._exitCallback&&this._exitCallback(new CommanderError(t,e,i)),process.exit(t)}action(t){return this._actionHandler=e=>{const i=this._args.length,n=e.slice(0,i);this._storeOptionsAsProperties?n[i]=this:n[i]=this.opts(),n.push(this);const s=t.apply(this,n);let o=this;for(;o.parent;)o=o.parent;o._actionResults.push(s)},this}createOption(t,e){return new Option(t,e)}addOption(t){const e=t.name(),i=t.attributeName();let n=t.defaultValue;if(t.negate||t.optional||t.required||"boolean"==typeof n){if(t.negate){const e=t.long.replace(/^--no-/,"--");n=!this._findOption(e)||this._getOptionValue(i)}void 0!==n&&this._setOptionValue(i,n)}return this.options.push(t),this.on("option:"+e,(e=>{const s=this._getOptionValue(i);if(null!==e&&t.parseArg)try{e=t.parseArg(e,void 0===s?n:s)}catch(i){if("commander.invalidOptionArgument"===i.code){const n=`error: option '${t.flags}' argument '${e}' is invalid. ${i.message}`;this._displayError(i.exitCode,i.code,n)}throw i}else null!==e&&t.variadic&&(e=t._concatValue(e,s));"boolean"==typeof s||void 0===s?null==e?this._setOptionValue(i,!t.negate&&(n||!0)):this._setOptionValue(i,e):null!==e&&this._setOptionValue(i,!t.negate&&e)})),this}_optionEx(t,e,i,n,s){const o=this.createOption(e,i);if(o.makeOptionMandatory(!!t.mandatory),"function"==typeof n)o.default(s).argParser(n);else if(n instanceof RegExp){const t=n;n=(e,i)=>{const n=t.exec(e);return n?n[0]:i},o.default(s).argParser(n)}else o.default(n);return this.addOption(o)}option(t,e,i,n){return this._optionEx({},t,e,i,n)}requiredOption(t,e,i,n){return this._optionEx({mandatory:!0},t,e,i,n)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){if(this._passThroughOptions=!!t,this.parent&&t&&!this.parent._enablePositionalOptions)throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");return this}storeOptionsAsProperties(t=!0){if(this._storeOptionsAsProperties=!!t,this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");return this}_setOptionValue(t,e){this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e}_getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}parse(t,e){if(void 0!==t&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");let n;switch(e=e||{},void 0===t&&(t=process.argv,process.versions&&process.versions.electron&&(e.from="electron")),this.rawArgs=t.slice(),e.from){case void 0:case"node":this._scriptPath=t[1],n=t.slice(2);break;case"electron":process.defaultApp?(this._scriptPath=t[1],n=t.slice(2)):n=t.slice(1);break;case"user":n=t.slice(0);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}return!this._scriptPath&&i.c[i.s]&&(this._scriptPath=i.c[i.s].filename),this._name=this._name||this._scriptPath&&o.basename(this._scriptPath,o.extname(this._scriptPath)),this._parseCommand([],n),this}parseAsync(t,e){return this.parse(t,e),Promise.all(this._actionResults).then((()=>this))}_executeSubCommand(t,e){e=e.slice();let n=!1;const a=[".js",".ts",".tsx",".mjs",".cjs"];this._checkForMissingMandatoryOptions();let h,l=this._scriptPath;!l&&i.c[i.s]&&(l=i.c[i.s].filename);try{const t=r.realpathSync(l);h=o.dirname(t)}catch(t){h="."}let p=o.basename(l,o.extname(l))+"-"+t._name;t._executableFile&&(p=t._executableFile);const m=o.join(h,p);let c;r.existsSync(m)?p=m:a.forEach((t=>{r.existsSync(`${m}${t}`)&&(p=`${m}${t}`)})),n=a.includes(o.extname(p)),"win32"!==process.platform?n?(e.unshift(p),e=incrementNodeInspectorPort(process.execArgv).concat(e),c=s.spawn(process.argv[0],e,{stdio:"inherit"})):c=s.spawn(p,e,{stdio:"inherit"}):(e.unshift(p),e=incrementNodeInspectorPort(process.execArgv).concat(e),c=s.spawn(process.execPath,e,{stdio:"inherit"}));["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((t=>{process.on(t,(()=>{!1===c.killed&&null===c.exitCode&&c.kill(t)}))}));const u=this._exitCallback;u?c.on("close",(()=>{u(new CommanderError(process.exitCode||0,"commander.executeSubCommandAsync","(close)"))})):c.on("close",process.exit.bind(process)),c.on("error",(e=>{if("ENOENT"===e.code){const e=`'${p}' does not exist\n - if '${t._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name`;throw new Error(e)}if("EACCES"===e.code)throw new Error(`'${p}' not executable`);if(u){const t=new CommanderError(1,"commander.executeSubCommandAsync","(error)");t.nestedError=e,u(t)}else process.exit(1)})),this.runningCommand=c}_dispatchSubcommand(t,e,i){const n=this._findCommand(t);n||this.help({error:!0}),n._executableHandler?this._executeSubCommand(n,e.concat(i)):n._parseCommand(e,i)}_parseCommand(t,e){const i=this.parseOptions(e);if(t=t.concat(i.operands),e=i.unknown,this.args=t.concat(e),t&&this._findCommand(t[0]))this._dispatchSubcommand(t[0],t.slice(1),e);else if(this._hasImplicitHelpCommand()&&t[0]===this._helpCommandName)1===t.length?this.help():this._dispatchSubcommand(t[1],[],[this._helpLongFlag]);else if(this._defaultCommandName)outputHelpIfRequested(this,e),this._dispatchSubcommand(this._defaultCommandName,t,e);else{!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),outputHelpIfRequested(this,i.unknown),this._checkForMissingMandatoryOptions();const checkForUnknownOptions=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},n=`command:${this.name()}`;if(this._actionHandler){checkForUnknownOptions();const i=this.args.slice();this._args.forEach(((t,e)=>{t.required&&null==i[e]?this.missingArgument(t.name):t.variadic&&(i[e]=i.splice(e),i.length=Math.min(e+1,i.length))})),i.length>this._args.length&&this._excessArguments(i),this._actionHandler(i),this.parent&&this.parent.emit(n,t,e)}else this.parent&&this.parent.listenerCount(n)?(checkForUnknownOptions(),this.parent.emit(n,t,e)):t.length?this._findCommand("*")?this._dispatchSubcommand("*",t,e):this.listenerCount("command:*")?this.emit("command:*",t,e):this.commands.length?this.unknownCommand():checkForUnknownOptions():this.commands.length?this.help({error:!0}):checkForUnknownOptions()}}_findCommand(t){if(t)return this.commands.find((e=>e._name===t||e._aliases.includes(t)))}_findOption(t){return this.options.find((e=>e.is(t)))}_checkForMissingMandatoryOptions(){for(let t=this;t;t=t.parent)t.options.forEach((e=>{e.mandatory&&void 0===t._getOptionValue(e.attributeName())&&t.missingMandatoryOptionValue(e)}))}parseOptions(t){const e=[],i=[];let n=e;const s=t.slice();function maybeOption(t){return t.length>1&&"-"===t[0]}let o=null;for(;s.length;){const t=s.shift();if("--"===t){n===i&&n.push(t),n.push(...s);break}if(!o||maybeOption(t)){if(o=null,maybeOption(t)){const e=this._findOption(t);if(e){if(e.required){const t=s.shift();void 0===t&&this.optionMissingArgument(e),this.emit(`option:${e.name()}`,t)}else if(e.optional){let t=null;s.length>0&&!maybeOption(s[0])&&(t=s.shift()),this.emit(`option:${e.name()}`,t)}else this.emit(`option:${e.name()}`);o=e.variadic?e:null;continue}}if(t.length>2&&"-"===t[0]&&"-"!==t[1]){const e=this._findOption(`-${t[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,t.slice(2)):(this.emit(`option:${e.name()}`),s.unshift(`-${t.slice(2)}`));continue}}if(/^--[^=]+=/.test(t)){const e=t.indexOf("="),i=this._findOption(t.slice(0,e));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,t.slice(e+1));continue}}if(maybeOption(t)&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&0===e.length&&0===i.length){if(this._findCommand(t)){e.push(t),s.length>0&&i.push(...s);break}if(t===this._helpCommandName&&this._hasImplicitHelpCommand()){e.push(t),s.length>0&&e.push(...s);break}if(this._defaultCommandName){i.push(t),s.length>0&&i.push(...s);break}}if(this._passThroughOptions){n.push(t),s.length>0&&n.push(...s);break}n.push(t)}else this.emit(`option:${o.name()}`,t)}return{operands:e,unknown:i}}opts(){if(this._storeOptionsAsProperties){const t={},e=this.options.length;for(let i=0;i<e;i++){const e=this.options[i].attributeName();t[e]=e===this._versionOptionName?this._version:this[e]}return t}return this._optionValues}_displayError(t,e,i){this._outputConfiguration.outputError(`${i}\n`,this._outputConfiguration.writeErr),this._exit(t,e,i)}missingArgument(t){const e=`error: missing required argument '${t}'`;this._displayError(1,"commander.missingArgument",e)}optionMissingArgument(t){const e=`error: option '${t.flags}' argument missing`;this._displayError(1,"commander.optionMissingArgument",e)}missingMandatoryOptionValue(t){const e=`error: required option '${t.flags}' not specified`;this._displayError(1,"commander.missingMandatoryOptionValue",e)}unknownOption(t){if(this._allowUnknownOption)return;const e=`error: unknown option '${t}'`;this._displayError(1,"commander.unknownOption",e)}_excessArguments(t){if(this._allowExcessArguments)return;const e=this._args.length,i=1===e?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${e} argument${i} but got ${t.length}.`;this._displayError(1,"commander.excessArguments",n)}unknownCommand(){const t=[this.name()];for(let e=this.parent;e;e=e.parent)t.unshift(e.name());const e=t.join(" "),i=`error: unknown command '${this.args[0]}'.`+(this._hasHelpOption?` See '${e} ${this._helpLongFlag}'.`:"");this._displayError(1,"commander.unknownCommand",i)}version(t,e,i){if(void 0===t)return this._version;this._version=t,e=e||"-V, --version",i=i||"output the version number";const n=this.createOption(e,i);return this._versionOptionName=n.attributeName(),this.options.push(n),this.on("option:"+n.name(),(()=>{this._outputConfiguration.writeOut(`${t}\n`),this._exit(0,"commander.version",t)})),this}description(t,e){return void 0===t&&void 0===e?this._description:(this._description=t,this._argsDescription=e,this)}alias(t){if(void 0===t)return this._aliases[0];let e=this;if(0!==this.commands.length&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");return e._aliases.push(t),this}aliases(t){return void 0===t?this._aliases:(t.forEach((t=>this.alias(t))),this)}usage(t){if(void 0===t){if(this._usage)return this._usage;const t=this._args.map((t=>humanReadableArgName(t)));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this._args.length?t:[]).join(" ")}return this._usage=t,this}name(t){return void 0===t?this._name:(this._name=t,this)}helpInformation(t){const e=this.createHelp();return void 0===e.helpWidth&&(e.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),e.formatHelp(this,e)}_getHelpContext(t){const e={error:!!(t=t||{}).error};let i;return i=e.error?t=>this._outputConfiguration.writeErr(t):t=>this._outputConfiguration.writeOut(t),e.write=t.write||i,e.command=this,e}outputHelp(t){let e;"function"==typeof t&&(e=t,t=void 0);const i=this._getHelpContext(t),n=[];let s=this;for(;s;)n.push(s),s=s.parent;n.slice().reverse().forEach((t=>t.emit("beforeAllHelp",i))),this.emit("beforeHelp",i);let o=this.helpInformation(i);if(e&&(o=e(o),"string"!=typeof o&&!Buffer.isBuffer(o)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(o),this.emit(this._helpLongFlag),this.emit("afterHelp",i),n.forEach((t=>t.emit("afterAllHelp",i)))}helpOption(t,e){if("boolean"==typeof t)return this._hasHelpOption=t,this;this._helpFlags=t||this._helpFlags,this._helpDescription=e||this._helpDescription;const i=_parseOptionFlags(this._helpFlags);return this._helpShortFlag=i.shortFlag,this._helpLongFlag=i.longFlag,this}help(t){this.outputHelp(t);let e=process.exitCode||0;0===e&&t&&"function"!=typeof t&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){const i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`);const n=`${t}Help`;return this.on(n,(t=>{let i;i="function"==typeof e?e({error:t.error,command:t.command}):e,i&&t.write(`${i}\n`)})),this}}function outputHelpIfRequested(t,e){t._hasHelpOption&&e.find((e=>e===t._helpLongFlag||e===t._helpShortFlag))&&(t.outputHelp(),t._exit(0,"commander.helpDisplayed","(outputHelp)"))}function humanReadableArgName(t){const e=t.name+(!0===t.variadic?"...":"");return t.required?"<"+e+">":"["+e+"]"}function _parseOptionFlags(t){let e,i;const n=t.split(/[ |,]+/);return n.length>1&&!/^[[<]/.test(n[1])&&(e=n.shift()),i=n.shift(),!e&&/^-[^-]$/.test(i)&&(e=i,i=void 0),{shortFlag:e,longFlag:i}}function incrementNodeInspectorPort(t){return t.map((t=>{if(!t.startsWith("--inspect"))return t;let e,i,n="127.0.0.1",s="9229";return null!==(i=t.match(/^(--inspect(-brk)?)$/))?e=i[1]:null!==(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(e=i[1],/^\d+$/.test(i[3])?s=i[3]:n=i[3]):null!==(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(e=i[1],n=i[3],s=i[4]),e&&"0"!==s?`${e}=${n}:${parseInt(s)+1}`:t}))}(e=t.exports=new Command).program=e,e.Command=Command,e.Option=Option,e.CommanderError=CommanderError,e.InvalidOptionArgumentError=InvalidOptionArgumentError,e.Help=Help}};