Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch @api private to official JSDoc #2018

Merged
merged 1 commit into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/argument.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Argument {
}

/**
* @api private
* @package internal use only
*/

_concatValue(value, previous) {
Expand Down Expand Up @@ -132,7 +132,7 @@ class Argument {
*
* @param {Argument} arg
* @return {string}
* @api private
* @private
*/

function humanReadableArgName(arg) {
Expand Down
95 changes: 47 additions & 48 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Command extends EventEmitter {

/**
* @returns {Command[]}
* @api private
* @private
*/

_getCommandAndAncestors() {
Expand Down Expand Up @@ -395,7 +395,7 @@ class Command extends EventEmitter {

/**
* @return {boolean}
* @api private
* @package internal use only
*/

_hasImplicitHelpCommand() {
Expand Down Expand Up @@ -456,7 +456,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
* @param {string} code an id string representing the error
* @param {string} message human-readable description of the error
* @return never
* @api private
* @private
*/

_exit(exitCode, code, message) {
Expand Down Expand Up @@ -522,7 +522,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
* @param {string} value
* @param {any} previous
* @param {string} invalidArgumentMessage
* @api private
* @private
*/

_callParseArg(target, value, previous, invalidArgumentMessage) {
Expand Down Expand Up @@ -608,7 +608,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
/**
* Internal implementation shared by .option() and .requiredOption()
*
* @api private
* @private
*/
_optionEx(config, flags, description, fn, defaultValue) {
if (typeof flags === 'object' && flags instanceof Option) {
Expand Down Expand Up @@ -769,7 +769,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
}

/**
* @api private
* @private
*/

_checkForBrokenPassThrough() {
Expand Down Expand Up @@ -877,7 +877,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
* Get user arguments from implied or explicit arguments.
* Side-effects: set _scriptPath if args included script. Used for default program name, and subcommand searches.
*
* @api private
* @private
*/

_prepareUserArgs(argv, parseOptions) {
Expand Down Expand Up @@ -980,7 +980,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
/**
* Execute a sub-command executable.
*
* @api private
* @private
*/

_executeSubCommand(subcommand, args) {
Expand Down Expand Up @@ -1105,7 +1105,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
}

/**
* @api private
* @private
*/

_dispatchSubcommand(commandName, operands, unknown) {
Expand All @@ -1128,7 +1128,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
* Invoke help directly if possible, or dispatch if necessary.
* e.g. help foo
*
* @api private
* @private
*/

_dispatchHelpCommand(subcommandName) {
Expand All @@ -1149,7 +1149,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
/**
* Check this.args against expected this._args.
*
* @api private
* @private
*/

_checkNumberOfArguments() {
Expand All @@ -1171,7 +1171,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
/**
* Process this.args using this._args and save as this.processedArgs!
*
* @api private
* @private
*/

_processArguments() {
Expand Down Expand Up @@ -1219,7 +1219,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
* @param {Promise|undefined} promise
* @param {Function} fn
* @return {Promise|undefined}
* @api private
* @private
*/

_chainOrCall(promise, fn) {
Expand All @@ -1237,7 +1237,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
* @param {Promise|undefined} promise
* @param {string} event
* @return {Promise|undefined}
* @api private
* @private
*/

_chainOrCallHooks(promise, event) {
Expand Down Expand Up @@ -1269,7 +1269,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
* @param {Command} subCommand
* @param {string} event
* @return {Promise|undefined}
* @api private
* @private
*/

_chainOrCallSubCommandHook(promise, subCommand, event) {
Expand All @@ -1288,7 +1288,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
* Process arguments in context of this command.
* Returns action result, in case it is a promise.
*
* @api private
* @private
*/

_parseCommand(operands, unknown) {
Expand All @@ -1306,15 +1306,15 @@ Expecting one of '${allowedValues.join("', '")}'`);
return this._dispatchHelpCommand(operands[1]);
}
if (this._defaultCommandName) {
outputHelpIfRequested(this, unknown); // Run the help for default command from parent rather than passing to default command
this._outputHelpIfRequested(unknown); // Run the help for default command from parent rather than passing to default command
return this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
}
if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
// probably missing subcommand and no handler, user needs help (and exit)
this.help({ error: true });
}

outputHelpIfRequested(this, parsed.unknown);
this._outputHelpIfRequested(parsed.unknown);
this._checkForMissingMandatoryOptions();
this._checkForConflictingOptions();

Expand Down Expand Up @@ -1372,7 +1372,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
/**
* Find matching command.
*
* @api private
* @private
*/
_findCommand(name) {
if (!name) return undefined;
Expand All @@ -1384,7 +1384,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
*
* @param {string} arg
* @return {Option}
* @api private
* @package internal use only
*/

_findOption(arg) {
Expand All @@ -1395,7 +1395,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
* Display an error message if a mandatory option does not have a value.
* Called after checking for help flags in leaf subcommand.
*
* @api private
* @private
*/

_checkForMissingMandatoryOptions() {
Expand All @@ -1412,7 +1412,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
/**
* Display an error message if conflicting options are used together in this.
*
* @api private
* @private
*/
_checkForConflictingLocalOptions() {
const definedNonDefaultOptions = this.options.filter(
Expand Down Expand Up @@ -1443,7 +1443,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
* Display an error message if conflicting options are used together.
* Called after checking for help flags in leaf subcommand.
*
* @api private
* @private
*/
_checkForConflictingOptions() {
// Walk up hierarchy so can call in subcommand after checking for displaying help.
Expand Down Expand Up @@ -1647,7 +1647,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
* Apply any option related environment variables, if option does
* not have a value from cli or client code.
*
* @api private
* @private
*/
_parseOptionsEnv() {
this.options.forEach((option) => {
Expand All @@ -1670,7 +1670,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
/**
* Apply any implied option values, if option is undefined or default value.
*
* @api private
* @private
*/
_parseOptionsImplied() {
const dualHelper = new DualOptions(this.options);
Expand All @@ -1694,7 +1694,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
* Argument `name` is missing.
*
* @param {string} name
* @api private
* @private
*/

missingArgument(name) {
Expand All @@ -1706,7 +1706,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
* `Option` is missing an argument.
*
* @param {Option} option
* @api private
* @private
*/

optionMissingArgument(option) {
Expand All @@ -1718,7 +1718,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
* `Option` does not have a value, and is a mandatory option.
*
* @param {Option} option
* @api private
* @private
*/

missingMandatoryOptionValue(option) {
Expand All @@ -1731,7 +1731,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
*
* @param {Option} option
* @param {Option} conflictingOption
* @api private
* @private
*/
_conflictingOption(option, conflictingOption) {
// The calling code does not know whether a negated option is the source of the
Expand Down Expand Up @@ -1768,7 +1768,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
* Unknown option `flag`.
*
* @param {string} flag
* @api private
* @private
*/

unknownOption(flag) {
Expand Down Expand Up @@ -1797,7 +1797,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
* Excess arguments, more than expected.
*
* @param {string[]} receivedArgs
* @api private
* @private
*/

_excessArguments(receivedArgs) {
Expand All @@ -1813,7 +1813,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
/**
* Unknown command.
*
* @api private
* @private
*/

unknownCommand() {
Expand Down Expand Up @@ -2023,7 +2023,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
}

/**
* @api private
* @private
*/

_getHelpContext(contextOptions) {
Expand Down Expand Up @@ -2149,22 +2149,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
});
return this;
}
}

/**
* Output help information if help flags specified
*
* @param {Command} cmd - command to output help for
* @param {Array} args - array of options to search for help flags
* @api private
*/
/**
* Output help information if help flags specified
*
* @param {Array} args - array of options to search for help flags
* @private
*/

function outputHelpIfRequested(cmd, args) {
const helpOption = cmd._hasHelpOption && args.find(arg => arg === cmd._helpLongFlag || arg === cmd._helpShortFlag);
if (helpOption) {
cmd.outputHelp();
// (Do not have all displayed text available so only passing placeholder.)
cmd._exit(0, 'commander.helpDisplayed', '(outputHelp)');
_outputHelpIfRequested(args) {
const helpOption = this._hasHelpOption && args.find(arg => arg === this._helpLongFlag || arg === this._helpShortFlag);
if (helpOption) {
this.outputHelp();
// (Do not have all displayed text available so only passing placeholder.)
this._exit(0, 'commander.helpDisplayed', '(outputHelp)');
}
}
}

Expand All @@ -2173,7 +2172,7 @@ function outputHelpIfRequested(cmd, args) {
*
* @param {string[]} args - array of arguments from node.execArgv
* @returns {string[]}
* @api private
* @private
*/

function incrementNodeInspectorPort(args) {
Expand Down
Loading