fix: render default arg/opt if equal to 0 (#264)

This commit is contained in:
Andrzej Wódkiewicz authored and GitHub committed 2021-08-11 09:26:18 -04:00
1 parent 095b4b4950
commit ca0af1908a
1 file changed
+4 -2
+4 -2
View File
@@ -100,7 +100,8 @@ export default class CommandHelp {
const body = renderList(args.map(a => {
const name = a.name.toUpperCase()
let description = a.description || ''
if (a.default) description = `[default: ${a.default}] ${description}`
// `a.default` is actually not always a string (typing bug), hence `toString()`
if (a.default || a.default?.toString() === '0') description = `[default: ${a.default}] ${description}`
if (a.options) description = `(${a.options.join('|')}) ${description}`
return [name, description ? dim(description) : undefined]
}), {stripAnsi: this.opts.stripAnsi, maxWidth: this.opts.maxWidth - 2})
@@ -144,7 +145,8 @@ export default class CommandHelp {
}
let right = flag.description || ''
if (flag.type === 'option' && flag.default) {
// `flag.default` is not always a string (typing bug), hence `toString()`
if (flag.type === 'option' && (flag.default || flag.default?.toString() === '0')) {
right = `[default: ${flag.default}] ${right}`
}
if (flag.required) right = `(required) ${right}`