Search in sources :

Example 11 with RunLast

use of picocli.CommandLine.RunLast in project besu by hyperledger.

the class CommandLineUtilsTest method multipleMainOptions.

@Test
public void multipleMainOptions() {
    final AbstractTestCommand testCommand = new TestMultiCommandWithDeps(mockLogger);
    testCommand.commandLine.parseWithHandlers(new RunLast(), defaultExceptionHandler(), "--option-enabled", "false", "--other-option-enabled", "false", "--option2", "20");
    verifyMultiOptionsConstraintLoggerCall(mockLogger, "--option2 and/or --option3 ignored because none of --option-enabled or --other-option-enabled was defined.");
    assertThat(testCommand.optionEnabled).isFalse();
    assertThat(testCommand.otherOptionEnabled).isFalse();
    assertThat(testCommand.option2).isEqualTo(20);
}
Also used : RunLast(picocli.CommandLine.RunLast) Test(org.junit.Test)

Example 12 with RunLast

use of picocli.CommandLine.RunLast in project besu by hyperledger.

the class CommandLineUtilsTest method optionsAreExpected.

@Test
public void optionsAreExpected() {
    final AbstractTestCommand testCommand = new TestCommandWithDeps(mockLogger);
    testCommand.commandLine.parseWithHandlers(new RunLast(), defaultExceptionHandler(), "--option2", "20", "--option3", "30", "--option4", "40");
    verifyNoMoreInteractions(mockLogger);
    assertThat(testCommand.optionEnabled).isTrue();
    assertThat(testCommand.option2).isEqualTo(20);
    assertThat(testCommand.option3).isEqualTo(30);
    assertThat(testCommand.option4).isEqualTo(40);
}
Also used : RunLast(picocli.CommandLine.RunLast) Test(org.junit.Test)

Example 13 with RunLast

use of picocli.CommandLine.RunLast in project besu by hyperledger.

the class CommandLineUtilsTest method noDependencies.

@Test
public void noDependencies() {
    final AbstractTestCommand testCommand = new TestCommandWithoutDeps(mockLogger);
    testCommand.commandLine.parseWithHandlers(new RunLast(), defaultExceptionHandler(), "--option-enabled", "false", "--option2", "20", "--option3", "30", "--option4", "40");
    verifyNoMoreInteractions(mockLogger);
    assertThat(testCommand.optionEnabled).isFalse();
    assertThat(testCommand.option2).isEqualTo(20);
    assertThat(testCommand.option3).isEqualTo(30);
    assertThat(testCommand.option4).isEqualTo(40);
}
Also used : RunLast(picocli.CommandLine.RunLast) Test(org.junit.Test)

Aggregations

RunLast (picocli.CommandLine.RunLast)13 CommandLine (picocli.CommandLine)6 Test (org.junit.Test)5 ParameterException (picocli.CommandLine.ParameterException)3 ParseResult (picocli.CommandLine.ParseResult)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ExecutionException (picocli.CommandLine.ExecutionException)2 IExceptionHandler2 (picocli.CommandLine.IExceptionHandler2)2 ValidationException (com.milaboratory.cli.ValidationException)1 File (java.io.File)1 IOException (java.io.IOException)1 StringPrintWriter (net.sf.jstuff.core.io.StringPrintWriter)1 RlpBlockExporter (org.hyperledger.besu.chainexport.RlpBlockExporter)1 JsonBlockImporter (org.hyperledger.besu.chainimport.JsonBlockImporter)1 RlpBlockImporter (org.hyperledger.besu.chainimport.RlpBlockImporter)1 BesuCommand (org.hyperledger.besu.cli.BesuCommand)1 BesuController (org.hyperledger.besu.controller.BesuController)1 BesuPluginContextImpl (org.hyperledger.besu.services.BesuPluginContextImpl)1 MetaborgException (org.metaborg.core.MetaborgException)1