From a30cec5b45f2dc49f8fc1c8c2c919eae64bef018 Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Thu, 14 Jul 2022 11:43:26 -0600 Subject: [PATCH 1/2] fix: help for single command CLIs --- src/help/docopts.ts | 2 +- src/help/index.ts | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/help/docopts.ts b/src/help/docopts.ts index 253b4afea..9e25ef8ca 100644 --- a/src/help/docopts.ts +++ b/src/help/docopts.ts @@ -80,7 +80,7 @@ export class DocOpts { } public toString(): string { - const opts = ['<%= command.id %>'] + const opts = this.cmd.id === '.' || this.cmd.id === '' ? [] : ['<%= command.id %>'] if (this.cmd.args) { const a = this.cmd.args?.map(arg => `[${arg.name.toUpperCase()}]`) || [] opts.push(...a) diff --git a/src/help/index.ts b/src/help/index.ts index 7fcc89737..68ce57009 100644 --- a/src/help/index.ts +++ b/src/help/index.ts @@ -5,7 +5,7 @@ import {error} from '../errors' import CommandHelp from './command' import RootHelp from './root' import {compact, sortBy, uniqBy} from '../util' -import {getHelpFlagAdditions, standardizeIDFromArgv} from './util' +import {getHelpFlagAdditions, standardizeIDFromArgv, toConfiguredId} from './util' import {HelpFormatter} from './formatter' import {toCached} from '../config/config' export {CommandHelp} from './command' @@ -215,10 +215,8 @@ export class Help extends HelpBase { } protected formatCommand(command: Interfaces.Command): string { - if (this.config.topicSeparator !== ':') { - command.id = command.id.replace(/:/g, this.config.topicSeparator) - command.aliases = command.aliases && command.aliases.map(a => a.replace(/:/g, this.config.topicSeparator)) - } + command.id = toConfiguredId(command.id, this.config) + command.aliases = command.aliases && command.aliases.map(a => toConfiguredId(a, this.config)) const help = this.getCommandHelpClass(command) return help.generate() From 32d8cb50c9af40ba7cfa9350846f27a805fa7fbb Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Thu, 14 Jul 2022 11:47:17 -0600 Subject: [PATCH 2/2] fix: revert formatCommand --- src/help/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/help/index.ts b/src/help/index.ts index 68ce57009..7fcc89737 100644 --- a/src/help/index.ts +++ b/src/help/index.ts @@ -5,7 +5,7 @@ import {error} from '../errors' import CommandHelp from './command' import RootHelp from './root' import {compact, sortBy, uniqBy} from '../util' -import {getHelpFlagAdditions, standardizeIDFromArgv, toConfiguredId} from './util' +import {getHelpFlagAdditions, standardizeIDFromArgv} from './util' import {HelpFormatter} from './formatter' import {toCached} from '../config/config' export {CommandHelp} from './command' @@ -215,8 +215,10 @@ export class Help extends HelpBase { } protected formatCommand(command: Interfaces.Command): string { - command.id = toConfiguredId(command.id, this.config) - command.aliases = command.aliases && command.aliases.map(a => toConfiguredId(a, this.config)) + if (this.config.topicSeparator !== ':') { + command.id = command.id.replace(/:/g, this.config.topicSeparator) + command.aliases = command.aliases && command.aliases.map(a => a.replace(/:/g, this.config.topicSeparator)) + } const help = this.getCommandHelpClass(command) return help.generate()