From 8099431b499fc9fce8a7407aae08c90d12236131 Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdxcode@users.noreply.github.com> Date: Sat, 24 Mar 2018 11:57:46 -0700 Subject: [PATCH] fix: move help into its own section --- src/root.ts | 10 +++++++++- test/commands/help.test.ts | 6 ++++-- test/root.test.ts | 6 ++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/root.ts b/src/root.ts index 227643fe..7efac1b1 100644 --- a/src/root.ts +++ b/src/root.ts @@ -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') @@ -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') + } + } diff --git a/test/commands/help.test.ts b/test/commands/help.test.ts index 2a479a04..76dcde68 100644 --- a/test/commands/help.test.ts +++ b/test/commands/help.test.ts @@ -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] diff --git a/test/root.test.ts b/test/root.test.ts index 6c0ba35e..7868d0e6 100644 --- a/test/root.test.ts +++ b/test/root.test.ts @@ -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]`))