Java Code Examples for org.apache.commons.cli.Options#getOption()

The following examples show how to use org.apache.commons.cli.Options#getOption() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestCommandLineOptionsFactory.java    From ia-rcade with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeduceFromMameRuntimeWithBooleanOption ()
        throws FileNotFoundException,
               IOException,
               InterruptedException,
               MameExecutionException {
    
    FakeMameRuntime mame = new FakeMameRuntime();
    List<InputStream> inputStreams = new ArrayList<>();
    inputStreams.add(
        new FileInputStream("src/test/resources/showconfig.txt"));
    inputStreams.add(
        new FileInputStream("src/test/resources/showusage.txt"));
    mame.setInputStreamsToReturn(inputStreams);
    CommandLineOptionsFactory clof = new CommandLineOptionsFactory ();
    Options mameOpts = clof.deduceFromMameRuntime(mame).getOptions();

    assertTrue(mameOpts.hasOption("waitvsync"));

    Option opt = mameOpts.getOption("waitvsync");

    assertFalse(opt.hasArg());

}
 
Example 2
Source File: TestCommandLineOptionsFactory.java    From ia-rcade with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeduceFromMameRuntimeWithNegativeBooleanOption ()
        throws FileNotFoundException,
               IOException,
               InterruptedException,
               MameExecutionException {
    
    FakeMameRuntime mame = new FakeMameRuntime();
    List<InputStream> inputStreams = new ArrayList<>();
    inputStreams.add(
        new FileInputStream("src/test/resources/showconfig.txt"));
    inputStreams.add(
        new FileInputStream("src/test/resources/showusage.txt"));
    mame.setInputStreamsToReturn(inputStreams);
    CommandLineOptionsFactory clof = new CommandLineOptionsFactory ();
    Options mameOpts = clof.deduceFromMameRuntime(mame).getOptions();

    assertTrue(mameOpts.hasOption("nowaitvsync"));

    Option opt = mameOpts.getOption("nowaitvsync");

    assertFalse(opt.hasArg());

}
 
Example 3
Source File: TestCommandLineOptionsFactory.java    From ia-rcade with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeduceFromMameRuntimeWithNonBooleanOption ()
        throws FileNotFoundException,
               IOException,
               InterruptedException,
               MameExecutionException {
    
    FakeMameRuntime mame = new FakeMameRuntime();
    List<InputStream> inputStreams = new ArrayList<>();
    inputStreams.add(
        new FileInputStream("src/test/resources/showconfig.txt"));
    inputStreams.add(
        new FileInputStream("src/test/resources/showusage.txt"));
    mame.setInputStreamsToReturn(inputStreams);
    CommandLineOptionsFactory clof = new CommandLineOptionsFactory ();
    Options mameOpts = clof.deduceFromMameRuntime(mame).getOptions();

    assertTrue(mameOpts.hasOption("rompath"));
    assertFalse(mameOpts.hasOption("norompath"));

    Option opt = mameOpts.getOption("rompath");

    assertTrue(opt.hasArg());

}
 
Example 4
Source File: TestCommandLineOptionsFactory.java    From ia-rcade with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeduceFromMameRuntimeWithNonBooleanOptionHavingDefaultValueLikeBoolean ()
        throws FileNotFoundException,
               IOException,
               InterruptedException,
               MameExecutionException {
    
    FakeMameRuntime mame = new FakeMameRuntime();
    List<InputStream> inputStreams = new ArrayList<>();
    inputStreams.add(
        new FileInputStream("src/test/resources/showconfig.txt"));
    inputStreams.add(
        new FileInputStream("src/test/resources/showusage.txt"));
    mame.setInputStreamsToReturn(inputStreams);
    CommandLineOptionsFactory clof = new CommandLineOptionsFactory ();
    Options mameOpts = clof.deduceFromMameRuntime(mame).getOptions();

    assertTrue(mameOpts.hasOption("prescale"));
    assertFalse(mameOpts.hasOption("noprescale"));

    Option opt = mameOpts.getOption("prescale");

    assertTrue(opt.hasArg());

}
 
Example 5
Source File: TestCommandLineOptionsFactory.java    From ia-rcade with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeduceFromMameRuntimeWithCommandOption ()
        throws FileNotFoundException,
               IOException,
               InterruptedException,
               MameExecutionException {
    
    FakeMameRuntime mame = new FakeMameRuntime();
    List<InputStream> inputStreams = new ArrayList<>();
    inputStreams.add(
        new FileInputStream("src/test/resources/showconfig.txt"));
    inputStreams.add(
        new FileInputStream("src/test/resources/showusage.txt"));
    mame.setInputStreamsToReturn(inputStreams);
    CommandLineOptionsFactory clof = new CommandLineOptionsFactory ();
    Options commands 
        = clof.deduceFromMameRuntime(mame).getCommands();

    assertTrue(commands.hasOption("help"));

    Option command = commands.getOption("help");

    assertFalse(command.hasArg());

}
 
Example 6
Source File: TestCommandLineOptionsFactory.java    From ia-rcade with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeduceFromMameRuntimeWithMediaTypeOption ()
        throws FileNotFoundException,
               IOException,
               InterruptedException,
               MameExecutionException {
    
    FakeMameRuntime mame = new FakeMameRuntime();
    List<InputStream> inputStreams = new ArrayList<>();
    inputStreams.add(
        new FileInputStream("src/test/resources/showconfig.txt"));
    inputStreams.add(
        new FileInputStream("src/test/resources/showusage.txt"));
    mame.setInputStreamsToReturn(inputStreams);
    CommandLineOptionsFactory clof = new CommandLineOptionsFactory ();
    Options mediaTypes 
        = clof.deduceFromMameRuntime(mame).getMediaTypes();

    assertTrue(mediaTypes.hasOption("cart"));

    Option opt = mediaTypes.getOption("cart");

    assertTrue(opt.hasArg());

}
 
Example 7
Source File: AbstractToolTest.java    From powsybl-core with Mozilla Public License 2.0 4 votes vote down vote up
protected void assertOption(Options options, String optionName, boolean isRequired, boolean hasArgument) {
    Option option = options.getOption(optionName);
    assertNotNull(option);
    assertEquals(isRequired, option.isRequired());
    assertEquals(hasArgument, option.hasArg());
}