Skip to content

Commit

Permalink
fix: show argument options in help (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
Junkern authored and jdx committed Jun 6, 2018
1 parent 52150c0 commit 0c8d1bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default class CommandHelp {
const name = a.name.toUpperCase()
let description = a.description || ''
if (a.default) 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})
return [
Expand Down
13 changes: 13 additions & 0 deletions test/command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@ OPTIONS
--flag2=flag2 [default: .] flag2 desc
--flag3=flag3 flag3 desc`))

test
.commandHelp(class extends Command {
static id = 'apps:create'
static args = [
{name: 'arg1', description: 'Show the options', options: ['option1', 'option2']}
]
})
.it('outputs with possible options', ctx => expect(ctx.commandHelp).to.equal(`USAGE
$ oclif apps:create [ARG1]
ARGUMENTS
ARG1 (option1|option2) Show the options`))

// class AppsCreate3 extends Command {
// static id = 'apps:create'
// static flags = {
Expand Down

0 comments on commit 0c8d1bf

Please sign in to comment.