Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Merged
merged 2 commits into from
Aug 11, 2021
Merged
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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}`
Expand Down