コード例 #1
0
ファイル: CLIUsageTest.java プロジェクト: testinfected/cli
  @Test
  public void aMoreComplexExampleThatUsesAMixOfDifferentArguments() throws Exception {
    cli =
        new CLI() {
          {
            flag("-h").describedAs("Human readable format");
            option("-b").alias("--block-size").takingArgument("SIZE").ofType(int.class);
            flag("-x");
            operand("input").as("INFILE").describedAs("The input file");
            operand("output", "OUTFILE", "The output file");
          }
        };

    cli.parse("-h", "--block-size", "1024", "-x", "input", "output", "extra", "more extra");
    assertEquals(6, cli.options().size());
    assertTrue(cli.has("-h"));
    assertEquals(1024, cli.get("--block-size"));
    assertTrue(cli.has("-x"));
    assertEquals("input", cli.get("input"));
    assertEquals("output", cli.get("output"));
    assertEquals(asList("extra", "more extra"), cli.others());
  }