@oclif/core
Advanced tools
Comparing version 3.26.9 to 3.27.0
@@ -157,8 +157,3 @@ "use strict"; | ||
if (flag.type === 'option') { | ||
let value = flag.helpValue || (this.opts.showFlagNameInTitle ? flag.name : '<value>'); | ||
if (!flag.helpValue && flag.options) { | ||
value = showOptions || this.opts.showFlagOptionsInTitle ? `${flag.options.join('|')}` : '<option>'; | ||
} | ||
if (flag.multiple) | ||
value += '...'; | ||
let value = docopts_1.DocOpts.formatUsageType(flag, this.opts.showFlagNameInTitle ?? false, this.opts.showFlagOptionsInTitle ?? showOptions); | ||
if (!value.includes('|')) | ||
@@ -165,0 +160,0 @@ value = chalk_1.default.underline(value); |
@@ -63,2 +63,3 @@ import { Command } from '../command'; | ||
constructor(cmd: Command.Loadable); | ||
static formatUsageType(flag: Command.Flag.Any, showFlagName: boolean, showOptions: boolean): string; | ||
static generate(cmd: Command.Loadable): string; | ||
@@ -65,0 +66,0 @@ toString(): string; |
@@ -76,2 +76,23 @@ "use strict"; | ||
} | ||
static formatUsageType(flag, showFlagName, showOptions) { | ||
if (flag.type !== 'option') | ||
return ''; | ||
let helpValues; | ||
if (flag.helpValue) { | ||
// if there is a given helpValue, use it | ||
helpValues = typeof flag.helpValue === 'string' ? [flag.helpValue] : flag.helpValue; | ||
} | ||
else if (flag.options) { | ||
// if there are options, show them if wanted | ||
helpValues = [showOptions ? flag.options.join('|') : '<option>']; | ||
} | ||
else if (showFlagName) { | ||
helpValues = [flag.name]; | ||
} | ||
else { | ||
// default to <value> | ||
helpValues = ['<value>']; | ||
} | ||
return helpValues.map((v) => `${v}${flag.multiple ? '...' : ''}`).join(' '); | ||
} | ||
static generate(cmd) { | ||
@@ -97,3 +118,3 @@ return new DocOpts(cmd).toString(); | ||
return name; | ||
return `${name}=<value>`; | ||
return `${name}=${DocOpts.formatUsageType(flag, false, true)}`; | ||
})); | ||
@@ -128,3 +149,3 @@ } | ||
if (flag.type === 'option') { | ||
type = flag.options ? ` ${flag.options.join('|')}` : ' <value>'; | ||
type = ` ${DocOpts.formatUsageType(flag, false, true)}`; | ||
} | ||
@@ -131,0 +152,0 @@ const element = `${flagName}${type}`; |
@@ -201,3 +201,3 @@ import { Command } from '../command'; | ||
type: 'option'; | ||
helpValue?: string; | ||
helpValue?: string | string[]; | ||
options?: readonly string[]; | ||
@@ -204,0 +204,0 @@ multiple?: boolean; |
{ | ||
"name": "@oclif/core", | ||
"description": "base library for oclif CLIs", | ||
"version": "3.26.9", | ||
"version": "3.27.0", | ||
"author": "Salesforce", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/oclif/core/issues", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
447619
11563