Esempio n. 1
0
 /**
  * Make sure that if there are args with multiple names (e.g. "-log" and "-verbose"), the usage
  * will only display it once.
  */
 public void repeatedArgs() {
   Cli<Args1> parser = singleCommandParser(Args1.class);
   CommandMetadata command =
       find(
           parser.getMetadata().getDefaultGroupCommands(),
           compose(equalTo("Args1"), CommandMetadata.nameGetter()));
   Assert.assertEquals(command.getAllOptions().size(), 8);
 }
Esempio n. 2
0
  private void verifyCommandOrdering(String[] commandNames, Class<?>... commands) {
    CliBuilder<Object> builder = Cli.buildCli("foo");
    for (Class<?> command : commands) {
      builder = builder.withCommand(command);
    }
    Cli<?> parser = builder.build();

    final List<CommandMetadata> commandParsers = parser.getMetadata().getDefaultGroupCommands();
    Assert.assertEquals(commandParsers.size(), commands.length);

    int i = 0;
    for (CommandMetadata commandParser : commandParsers) {
      Assert.assertEquals(commandParser.getName(), commandNames[i++]);
    }
  }