Group Annotation

@Group

The @Group 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.

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")
@Group(name = "advanced",
       defaultCommand = GroupMember.class,
       commands = { Tool.class })
public class GroupMember { }

Here we use the @Group annotation to place our command in the advanced group. We also specify that we are the default command for that group and that the group also contains the Tool.class command.

Note that since we are annotating directly on an @Command annotation class we don’t need to specify ourselves in the list of commands

Using as argument to @Cli

When used as an argument to an @Cli annotation via the groups field then we must specify all the commands in the commands field of the @Group annotation e.g.

@Cli(name = "cli",
         groups = {
           @Group(name = "advanced",
                  defaultCommand = GroupMember.class,
                  commands = { GroupMember.class, Tool.class })
         })
public class GroupCli { }

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.