command-line-interface
Advanced tools
Comparing version 3.2.0 to 3.2.1
@@ -6,2 +6,5 @@ "use strict"; | ||
let type; | ||
if (optionDefinition.type === 'boolean' && optionDefinition.defaultOption) { | ||
throw new errors_1.errors.OptionInvalid(`Option '${optionDefinition.name}' must not be a default option, because it is boolean.`); | ||
} | ||
switch (optionDefinition.type) { | ||
@@ -8,0 +11,0 @@ case 'boolean': |
@@ -24,3 +24,8 @@ "use strict"; | ||
if (defaultOption) { | ||
synopsis += ` ${optionToString_1.optionToString({ option: defaultOption })}`; | ||
if (defaultOption.isRequired) { | ||
synopsis += ` ${optionToString_1.optionToString({ option: defaultOption })}`; | ||
} | ||
else { | ||
synopsis += ` [${optionToString_1.optionToString({ option: defaultOption })}]`; | ||
} | ||
} | ||
@@ -27,0 +32,0 @@ return synopsis; |
@@ -5,8 +5,10 @@ "use strict"; | ||
var _a; | ||
const prefix = option.defaultOption ? '' : '--'; | ||
const parameterName = (_a = option.parameterName, (_a !== null && _a !== void 0 ? _a : option.type)); | ||
const multiplier = option.multiple === undefined || option.multiple === 'off' ? '' : '[]'; | ||
const parameterDescription = option.type === 'boolean' ? '' : ` {underline ${parameterName}${multiplier}}`; | ||
return `${prefix}${option.name}${parameterDescription}`; | ||
const parameterDescription = option.type === 'boolean' ? '' : `{underline ${parameterName}${multiplier}}`; | ||
if (option.defaultOption) { | ||
return parameterDescription; | ||
} | ||
return `--${option.name}${parameterDescription ? ' ' : ''}${parameterDescription}`; | ||
}; | ||
exports.optionToString = optionToString; |
@@ -0,1 +1,8 @@ | ||
## [3.2.1](https://github.com/thenativeweb/command-line-interface/compare/3.2.0...3.2.1) (2020-02-07) | ||
### Bug Fixes | ||
* Fix display of default option name. ([#28](https://github.com/thenativeweb/command-line-interface/issues/28)) ([7e2605e](https://github.com/thenativeweb/command-line-interface/commit/7e2605e8552d6d63dbabec8f0feec875235e616c)) | ||
# [3.2.0](https://github.com/thenativeweb/command-line-interface/compare/3.1.3...3.2.0) (2020-02-07) | ||
@@ -2,0 +9,0 @@ |
@@ -10,2 +10,6 @@ import { OptionDefinition as CLAOptionDefinition } from 'command-line-args'; | ||
if (optionDefinition.type === 'boolean' && optionDefinition.defaultOption) { | ||
throw new errors.OptionInvalid(`Option '${optionDefinition.name}' must not be a default option, because it is boolean.`); | ||
} | ||
switch (optionDefinition.type) { | ||
@@ -12,0 +16,0 @@ case 'boolean': |
@@ -37,3 +37,7 @@ import { Command } from '../elements/Command'; | ||
if (defaultOption) { | ||
synopsis += ` ${optionToString({ option: defaultOption })}`; | ||
if (defaultOption.isRequired) { | ||
synopsis += ` ${optionToString({ option: defaultOption })}`; | ||
} else { | ||
synopsis += ` [${optionToString({ option: defaultOption })}]`; | ||
} | ||
} | ||
@@ -40,0 +44,0 @@ |
@@ -6,11 +6,13 @@ import { OptionDefinition } from '../elements/OptionDefinition'; | ||
}): string => { | ||
const prefix = option.defaultOption ? '' : '--'; | ||
const parameterName = option.parameterName ?? option.type; | ||
const multiplier = option.multiple === undefined || option.multiple === 'off' ? '' : '[]'; | ||
const parameterDescription = option.type === 'boolean' ? '' : ` {underline ${parameterName}${multiplier}}`; | ||
const parameterDescription = option.type === 'boolean' ? '' : `{underline ${parameterName}${multiplier}}`; | ||
return `${prefix}${option.name}${parameterDescription}`; | ||
if (option.defaultOption) { | ||
return parameterDescription; | ||
} | ||
return `--${option.name}${parameterDescription ? ' ' : ''}${parameterDescription}`; | ||
}; | ||
export { optionToString }; |
{ | ||
"name": "command-line-interface", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"description": "command-line-interface is a foundation for CLI applications.", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
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
57186
1151