Summary
When multiple group commands have child subcommands with the same name (e.g. add, list, remove), the dynamic completion (--aesh-complete) returns the correct subcommand names but wrong descriptions. The descriptions appear to come from whichever command was last registered with that name, rather than from the specific group's child.
Reproduction
Given a CLI with multiple group commands sharing child names:
jbang alias add -> "Add alias for script reference."
jbang catalog add -> "Add a catalog."
jbang template add -> "Add template for script reference."
jbang deps add -> "Add dependencies to a jbang file."
jbang trust add -> "Add trust domains."
Completion output:
$ jbang --aesh-complete -- "alias "
add Add dependencies to a jbang file. # WRONG - should be "Add alias for script reference."
list List active configuration values # WRONG - should be "Lists locally defined aliases..."
remove Remove trust domains. # WRONG - should be "Remove existing alias."
$ jbang --aesh-complete -- "catalog "
add Add dependencies to a jbang file. # WRONG
list List active configuration values # WRONG
remove Remove trust domains. # WRONG
$ jbang --aesh-complete -- "config "
get Get a configuration value # correct
set Set a configuration value # correct
list Lists installed commands. # WRONG - should be "List active configuration values"
Note that config get, config set, config unset show correct descriptions because those names are unique across all group commands.
Expected behavior
Each group command's completion should show the descriptions from its own children, not from a shared/global lookup.
Root cause
The performDynamicCompletion() method likely looks up subcommand descriptions by name from a flat map or the last-registered command, rather than scoping the lookup to the specific group command being completed.
Context
Found in jbang (jbangdev/jbang#2453) where alias, template, catalog, trust, deps, and config all have add/list/remove subcommands.
Summary
When multiple group commands have child subcommands with the same name (e.g.
add,list,remove), the dynamic completion (--aesh-complete) returns the correct subcommand names but wrong descriptions. The descriptions appear to come from whichever command was last registered with that name, rather than from the specific group's child.Reproduction
Given a CLI with multiple group commands sharing child names:
Completion output:
Note that
config get,config set,config unsetshow correct descriptions because those names are unique across all group commands.Expected behavior
Each group command's completion should show the descriptions from its own children, not from a shared/global lookup.
Root cause
The
performDynamicCompletion()method likely looks up subcommand descriptions by name from a flat map or the last-registered command, rather than scoping the lookup to the specific group command being completed.Context
Found in jbang (jbangdev/jbang#2453) where
alias,template,catalog,trust,deps, andconfigall haveadd/list/removesubcommands.