Skip to content

Commit

Permalink
fix: move help into its own section
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Mar 24, 2018
1 parent fa7f72a commit 8099431
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export default class RootHelp {
let description = this.config.pjson.oclif.description || this.config.pjson.description || ''
description = this.render(description)
description = description.split('\n')[0]
description = `${this.config.userAgent}\n${description}`
let output = compact([
description,
this.version(),
this.usage(),
this.description(),
]).join('\n\n')
Expand All @@ -49,4 +49,12 @@ export default class RootHelp {
indent(wrap(description, this.opts.maxWidth - 2, {trim: false, hard: true}), 2),
].join('\n')
}

protected version(): string {
return [
bold('VERSION'),
indent(wrap(this.config.userAgent, this.opts.maxWidth - 2, {trim: false, hard: true}), 2),
].join('\n')
}

}
6 changes: 4 additions & 2 deletions test/commands/help.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ OPTIONS
.stdout()
.command(['help'])
.it('shows root help', ctx => {
expect(ctx.stdout).to.equal(`${UA}
standard help for oclif
expect(ctx.stdout).to.equal(`standard help for oclif
VERSION
${UA}
USAGE
$ oclif [COMMAND]
Expand Down
6 changes: 4 additions & 2 deletions test/root.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ const test = base
describe('root help', () => {
test
.rootHelp()
.it(ctx => expect(ctx.commandHelp).to.equal(`${UA}
standard help for oclif
.it(ctx => expect(ctx.commandHelp).to.equal(`standard help for oclif
VERSION
${UA}
USAGE
$ oclif [COMMAND]`))
Expand Down

0 comments on commit 8099431

Please sign in to comment.