Skip to content

Commit

Permalink
fix: account for aliases when converting spaced commands to commandID (
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Aug 23, 2021
1 parent 38fd5e6 commit b8ee9b2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/help/util.ts
Expand Up @@ -48,7 +48,14 @@ function collateSpacedCmdIDFromArgs(argv: string[], config: IConfig): string[] {
const finalizeId = (s?: string) => s ? [...final, s].join(':') : final.join(':')

const hasSubCommandsWithArgs = () => {
const subCommands = config.commands.filter(c => (c.id).startsWith(finalizeId()))
const id = finalizeId()
/**
* Get a list of sub commands for the current command id. A command is returned as a subcommand under either
* of these conditions:
* 1. the `id` start with the current command id.
* 2. any of the aliases start with the current command id.
*/
const subCommands = config.commands.filter(c => (c.id).startsWith(id) || c.aliases.some(a => a.startsWith(id)))
return Boolean(subCommands.find(cmd => cmd.strict === false || cmd.args?.length > 0))
}

Expand Down

0 comments on commit b8ee9b2

Please sign in to comment.