这是indexloc提供的服务,不要输入任何密码
Skip to content

Nested Arggroup options are printed in the Outer Arggroup when Nested is ordered after Outer #2413

@andriikovalov

Description

@andriikovalov

Test code:

    @Command(name = "test", sortOptions = false)
    public static class Test {
        @ArgGroup(exclusive = false, heading = "Outer group\n", order = 10)
        private Outer outer;

        private static class Outer {
            @Option(names = "--outer-opt", description = "Outer option")
            private String oo;

            @ArgGroup(exclusive = false, heading = "Nested group\n", order = 20)
            private Nested nested;
        }

        private static class Nested {
            @Option(names = "--nested-opt", description = "Nested option")
            private String no;
        }

        public static void main(String[] args) {
            new CommandLine(new Test()).usage(System.out);
        }
    }

Expected output:

Usage: test [[--outer-opt=<oo>] [[--nested-opt=<no>]]]
Outer group
      --outer-opt=<oo>    Outer option
Nested group
      --nested-opt=<no>   Nested option

Actual

Usage: test [[--outer-opt=<oo>] [[--nested-opt=<no>]]]
Outer group
      --outer-opt=<oo>    Outer option
      --nested-opt=<no>   Nested option
Nested group

If I switch the order, everything works as expected - the nested option is in the nested group.

Tested against v4.7.7 and current master.

Metadata

Metadata

Assignees

No one assigned

    Labels

    theme: arg-groupAn issue or change related to argument groupstheme: usagehelpAn issue or change related to the usage help messagetype: bug 🐛

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions