Skip to content

Commit ca0af19

Browse files
authored
fix: render default arg/opt if equal to 0 (#264)
1 parent 095b4b4 commit ca0af19

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/command.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ export default class CommandHelp {
100100
const body = renderList(args.map(a => {
101101
const name = a.name.toUpperCase()
102102
let description = a.description || ''
103-
if (a.default) description = `[default: ${a.default}] ${description}`
103+
// `a.default` is actually not always a string (typing bug), hence `toString()`
104+
if (a.default || a.default?.toString() === '0') description = `[default: ${a.default}] ${description}`
104105
if (a.options) description = `(${a.options.join('|')}) ${description}`
105106
return [name, description ? dim(description) : undefined]
106107
}), {stripAnsi: this.opts.stripAnsi, maxWidth: this.opts.maxWidth - 2})
@@ -144,7 +145,8 @@ export default class CommandHelp {
144145
}
145146

146147
let right = flag.description || ''
147-
if (flag.type === 'option' && flag.default) {
148+
// `flag.default` is not always a string (typing bug), hence `toString()`
149+
if (flag.type === 'option' && (flag.default || flag.default?.toString() === '0')) {
148150
right = `[default: ${flag.default}] ${right}`
149151
}
150152
if (flag.required) right = `(required) ${right}`

0 commit comments

Comments
 (0)