diff --git a/src/help/command.ts b/src/help/command.ts index 81969ae4..787b49e9 100644 --- a/src/help/command.ts +++ b/src/help/command.ts @@ -156,20 +156,18 @@ export class CommandHelp extends HelpFormatter { const cmd = this.command let description: string[] | undefined - if (this.opts.hideCommandSummaryInDescription) { description = (cmd.description || '').split(POSSIBLE_LINE_FEED).slice(1) } else if (cmd.description) { - description = [ - ...(cmd.summary || '').split(POSSIBLE_LINE_FEED), + const summary = cmd.summary ? `${cmd.summary}\n` : null + description = summary ? [ + ...summary.split(POSSIBLE_LINE_FEED), ...(cmd.description || '').split(POSSIBLE_LINE_FEED), - ] + ] : (cmd.description || '').split(POSSIBLE_LINE_FEED) } if (description) { - // Lines separated with only one newline or more than 2 can be hard to read in the terminal. - // Always separate by two newlines. - return this.wrap(compact(description).join('\n\n')) + return this.wrap(description.join('\n')) } } diff --git a/test/help/format-command.test.ts b/test/help/format-command.test.ts index d208d87a..53ff6a57 100644 --- a/test/help/format-command.test.ts +++ b/test/help/format-command.test.ts @@ -25,6 +25,7 @@ describe('formatCommand', () => { static aliases = ['app:init', 'create'] static description = `first line + multiline help` static enableJsonFlag = true @@ -222,7 +223,7 @@ DESCRIPTION .commandHelp(class extends Command { static id = 'apps:create' - static description = 'description of apps:create\nthese values are after and will show up in the command description' + static description = 'description of apps:create\n\nthese values are after and will show up in the command description' static aliases = ['app:init', 'create'] @@ -259,7 +260,7 @@ ALIASES .commandHelp(class extends Command { static id = 'apps:create' - static description = 'root part of the description\nThe <%= config.bin %> CLI has <%= command.id %>' + static description = 'root part of the description\n\nThe <%= config.bin %> CLI has <%= command.id %>' static disableJsonFlag = true }) @@ -275,7 +276,7 @@ DESCRIPTION .commandHelp(class extends Command { static id = 'apps:create' - static description = 'root part of the description\r\nusing both carriage \nreturn and new line' + static description = 'root part of the description\r\n\nusing both carriage \n\nreturn and new line' static disableJsonFlag = true })