Skip to content
Open
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
21 changes: 20 additions & 1 deletion lib/option.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Option {
this.conflictsWith = [];
this.implied = undefined;
this.helpGroupHeading = undefined; // soft initialised when option added to command
this.attribName = undefined;
}

/**
Expand Down Expand Up @@ -194,6 +195,19 @@ class Option {
return this;
}

/**
* Allow to change the attribute name of this option.
*
* @param {string} attributeName is used for a alternated attribute name
* @return {Option}
*/

setAttributeName(attributeName) {
if (typeof attributeName === 'string') {
this.attribName = attributeName;
}
return this;
}
/**
* Return option name.
*
Expand All @@ -209,12 +223,17 @@ class Option {

/**
* Return option name, in a camelcase format that can be used
* as an object attribute key.
* as an object attribute key.
* This method now uses alternativly the this.attributeName when it is set otherwise
* it will still use the option name as before
*
* @return {string}
*/

attributeName() {
if (typeof this.attribName === 'string') {
return this.attribName;
}
if (this.negate) {
return camelcase(this.name().replace(/^no-/, ''));
}
Expand Down
Loading