if (!groupAnno.defaultCommand().equals(Group.NO_DEFAULT.class)) { defaultCommandClass = groupAnno.defaultCommand(); defaultCommand = CollectionUtils.find(allCommands, new CommandTypeFinder(defaultCommandClass)); if (null == defaultCommand) { List<CommandMetadata> groupCommands = new ArrayList<CommandMetadata>(groupAnno.commands().length); CommandMetadata groupCommand = null; for (Class commandClass : groupAnno.commands()) { groupCommand = CollectionUtils.find(allCommands, new CommandTypeFinder(commandClass)); if (null == groupCommand) { new GroupFinder(groupAnno.name())); if (groupMetadata == null) { if (StringUtils.containsWhitespace(groupAnno.name())) { subGroupPath = StringUtils.join(StringUtils.split(groupAnno.name()), " "); groupMetadata = subGroups.get(subGroupPath); groupMetadata = loadCommandGroup(groupAnno.name(), groupAnno.description(), groupAnno.hidden(), Collections.<CommandGroupMetadata> emptyList(), defaultCommand, groupCommands); if (!StringUtils.containsWhitespace(groupAnno.name())) {
List<CommandGroupMetadata> groups = new ArrayList<CommandGroupMetadata>(); for (Group groupAnno : cliConfig.groups()) { String groupName = groupAnno.name(); String subGroupPath = null; if (StringUtils.containsWhitespace(groupName)) { subGroupPath = StringUtils.join(StringUtils.split(groupAnno.name()), ' '); for (Class<?> cls : groupAnno.commands()) { groupCommands.add(loadCommand(cls, new HashMap<>(baseHelpSections))); groupAnno.description(), groupAnno.hidden(), Collections.<CommandGroupMetadata>emptyList(), !groupAnno.defaultCommand().equals(Group.NO_DEFAULT.class) ? loadCommand(groupAnno.defaultCommand(), baseHelpSections) : null, groupCommands);
@Group(name = "singleGroup", description = "a single group", defaultCommand = CommandWithGroupAnnotation.class,commands = {CommandAdd.class}) @Command(name = "commandWithGroup", description = "A command with a group annotation") public class CommandWithGroupAnnotation extends AbstractGroupAnnotationCommand { }
@Group(name = "singleGroup subGroup", description = "a single sub-group", defaultCommand = CommandWithSubGroupAnnotation.class,commands = {CommandAdd.class}) @Command(name = "commandWithGroup", description = "A command with a group annotation") public class CommandWithSubGroupAnnotation extends AbstractGroupAnnotationCommand { }
@com.github.rvesse.airline.annotations.Cli(name = "test", groups = { @Group(name = "foo bar", defaultCommand = Help.class, commands = { Help.class }) }) private static class SubGroupsCli01 { }
@Groups({ @Group(name = "groupInsideOfGroups subGroup", description = "my nested sub-group", defaultCommand = CommandWithSubGroupsAnnotation.class,commands = {CommandAdd.class}), @Group(name = "groupInsideOfGroups", description = "top level group", commands = { CommandWithSubGroupsAnnotation.class }) }) @Command(name = "commandWithSubGroupsAnno", description = "A command with a groups annotation defining a sub-group") public class CommandWithSubGroupsAnnotation extends AbstractGroupAnnotationCommand { @Option(name = "-v", type = OptionType.GROUP) public boolean verbose = false; }
@Cli(name = "git", description = "the stupid content tracker", defaultCommand = Help.class, commands = { Help.class, Add.class }, groups = { @Group(name = "remote", description = "Manage set of tracked repositories", defaultCommand = RemoteShow.class, commands = { RemoteShow.class, RemoteAdd.class }) } ) //@formatter:on public class GitWithCliAnnotation extends Git { public static void run(String[] args) { com.github.rvesse.airline.Cli<Runnable> gitParser = new com.github.rvesse.airline.Cli<Runnable>( GitWithCliAnnotation.class); gitParser.parse(args).run(); } }
}, groups = { @Group(name = "agent", description = "Manage agents", defaultCommand = AgentShowCommand.class,
@Groups({ @Group(name = "groupInsideOfGroups", description = "my nested group", defaultCommand = CommandWithGroupsAnnotation.class,commands = {CommandAdd.class}) }) @Command(name = "commandWithGroupsAnno", description = "A command with a groups annotation") public class CommandWithGroupsAnnotation extends AbstractGroupAnnotationCommand { @Option(name = "-v", type = OptionType.GROUP) public boolean verbose = false; }
@Cli(name = "git", description = "the stupid content tracker", defaultCommand = Help.class, commands = { Help.class, Add.class }, groups = { @Group(name = "remote", description = "Manage set of tracked repositories", defaultCommand = RemoteShow.class, commands = { RemoteShow.class, RemoteAdd.class }) }, parserConfiguration = @Parser( aliases = { @Alias( name = "foo", arguments = { "remote", "show" } ) }) ) //@formatter:on public class GitWithCliAnnotation2 extends Git { public static void run(String[] args) { com.github.rvesse.airline.Cli<Runnable> gitParser = new com.github.rvesse.airline.Cli<Runnable>( GitWithCliAnnotation2.class); gitParser.parse(args).run(); } }