Skip to content

Commit

Permalink
fix: read options if flagValue is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 17, 2018
1 parent cc0ab72 commit abe43d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ export default class CommandHelp {
let left = label.join(', ')
if (flag.type === 'option') {
let value = flag.helpValue || flag.name
if (!value.includes('(')) value = underline(value)
if (!flag.helpValue && flag.options) {
value = flag.options.join('|')
}
if (!value.includes('|')) value = underline(value)
left += `=${value}`
}

Expand Down
4 changes: 2 additions & 2 deletions test/command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ ALIASES
.commandHelp(class extends Command {
static id = 'apps:create'
static flags = {
myenum: flags.enum({options: ['a', 'b', 'c']}),
myenum: flags.string({options: ['a', 'b', 'c']}),
}})
.it('outputs with description', ctx => expect(ctx.commandHelp).to.equal(`USAGE
$ oclif apps:create
OPTIONS
--myenum=(a|b|c)`))
--myenum=a|b|c`))

test
.commandHelp(class extends Command {
Expand Down

0 comments on commit abe43d8

Please sign in to comment.