I believe group-name only applies to the command position (i.e. the first one). Myself, I only use compadd directly for custom completion of command options, in this case, it is the -x message
that gets used:
Contents of _foo
:
#compdef foo
A=( -h --help foo bar baz )
compadd -J group1 -X expl1 -x msg1 -a A
B=( clown-fish hippo )
compadd -J group2 -X expl2 -x msg2 -a B
then somewhere else:
function foo { echo $* }
compdef _foo foo
When I run this completion, I get the options grouped by message.