picocli icon indicating copy to clipboard operation
picocli copied to clipboard

Duplicate help output for ArgGroup from a Mixin

Open s-falke opened this issue 7 months ago • 1 comments

The following example uses a @Mixin in order to import an @ArgGroup:

import picocli.CommandLine;
import picocli.CommandLine.ArgGroup;
import picocli.CommandLine.Command;
import picocli.CommandLine.Mixin;
import picocli.CommandLine.Option;

@Command
class MyMixin
{
    @ArgGroup(exclusive = true, multiplicity = "1")
    Exclusive exclusive;

    static class Exclusive {
        @Option(names = "-a", required = true, description = "Use A.") int a;
        @Option(names = "-b", required = true, description = "Use B.") int b;
        @Option(names = "-c", required = true, description = "Use C.") int c;
    }
}

@Command(mixinStandardHelpOptions = true, name = "exclusivedemo")
public class MutuallyExclusiveOptionsDemo {
    @Mixin
    MyMixin mixin;

    public static void main(String... args) {
        int exitCode = new CommandLine(new MutuallyExclusiveOptionsDemo()).execute(args);
        System.exit(exitCode);
    }
}

The help output generated using picocli 4.7.6 lists the options -a, -b, and -c twice:

Usage: exclusivedemo [-hV] (-a=<a> | -b=<b> | -c=<c>)
  -a=<a>          Use A.
  -a=<a>          Use A.
  -b=<b>          Use B.
  -b=<b>          Use B.
  -c=<c>          Use C.
  -c=<c>          Use C.
  -h, --help      Show this help message and exit.
  -V, --version   Print version information and exit.

In contrast, picocli 4.7.5 lists them only once:

Usage: exclusivedemo [-hV] (-a=<a> | -b=<b> | -c=<c>)
  -a=<a>          Use A.
  -b=<b>          Use B.
  -c=<c>          Use C.
  -h, --help      Show this help message and exit.
  -V, --version   Print version information and exit.

s-falke avatar Jun 24 '24 12:06 s-falke