Groups Annotation

@Groups

The @Groups annotation is used to specify group information. This may be done as an alternative or in addition to using the relevant fields of the @Command or @Cli annotations to specify groups.

This annotation should be used when you wish to make your @Command annotated class part of multiple groups since you can’t directly place multiple @Group annotations on a class.

Generally we recommend that you use the groups field of the @Cli annotation to specify groups however this annotation can be useful if you are dynamically constructing your CLI and want to allow individual commands to specify their group memberships.

Use on an @Command class

For example:

@Command(name = "group-member")
@Groups({
     @Group(name = "advanced",
            defaultCommand = GroupMember.class,
            commands = { Tool.class }),
      @Group(name = "other",
             commands = { GroupMember.class })
})
public class GroupMember { }

Here we use the @Groups annotation to place our command in both the advanced group and the other group. Please see the @Group page for more information on using that annotation.


Improving this Documentation

This documentation is itself open source and lives in GitHub under the docs/ directory.

I am not a professional technical writer and as the developer of this software I can often make assumptions of knowledge that you as a user reading this may not have. Improvements to the documentation are always welcome, if you have suggestions for the documentation please submit pull requests to the main branch.