Skip to content

Commit b8ee9b2

Browse files
authored
fix: account for aliases when converting spaced commands to commandID (#232)
1 parent 38fd5e6 commit b8ee9b2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/help/util.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,14 @@ function collateSpacedCmdIDFromArgs(argv: string[], config: IConfig): string[] {
4848
const finalizeId = (s?: string) => s ? [...final, s].join(':') : final.join(':')
4949

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

0 commit comments

Comments
 (0)