Search in sources :

Example 31 with CommandLine

use of picocli.CommandLine in project vcell by virtualcell.

the class VCellSbmlSimCLI method parse.

void parse(String[] args) {
    new CommandLine(this).parse(args);
    String parsedCommand = this.command;
    if (parsedCommand == null || Command.valueOf(parsedCommand) == null) {
        throw new RuntimeException("command '" + parsedCommand + "' not found");
    }
    this.cmd = Command.valueOf(parsedCommand);
}
Also used : CommandLine(picocli.CommandLine)

Example 32 with CommandLine

use of picocli.CommandLine in project drools by kiegroup.

the class ChineseLunarYearsTest method testCLI.

@Test
public void testCLI() throws Exception {
    File tempFile = File.createTempFile("xls2dmn", ".dmn");
    final DMNRuntime dmnRuntime = getRuntime(new CommandLine(new App())::execute, tempFile, new String[] { "src/test/resources/ChineseLunarYears.xlsx", tempFile.toString() });
    DMNModel dmnModel = dmnRuntime.getModels().get(0);
    DMNContext dmnContext = dmnRuntime.newContext();
    dmnContext.set("Date", LocalDate.of(2021, 4, 1));
    DMNResult dmnResult = dmnRuntime.evaluateAll(dmnModel, dmnContext);
    LOG.debug("{}", dmnResult);
    assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
    assertThat(dmnResult.getDecisionResultByName("Chinese Year").getResult(), is("Golden Ox"));
}
Also used : CommandLine(picocli.CommandLine) DMNResult(org.kie.dmn.api.core.DMNResult) DMNContext(org.kie.dmn.api.core.DMNContext) File(java.io.File) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) DMNModel(org.kie.dmn.api.core.DMNModel) Test(org.junit.Test)

Example 33 with CommandLine

use of picocli.CommandLine in project TOSCAna by StuPro-TOSCAna.

the class CliMain method main.

public void main(String[] args) {
    // Activate ANSI on Windows
    AnsiConsole.systemInstall();
    System.setProperty("picocli.ansi", "true");
    // System Property gets set here, because picocli.trace must be set before CommandLine starts
    String input = String.join("", args);
    if (input.endsWith("-m")) {
        System.setProperty("picocli.trace", "DEBUG");
    } else if (input.endsWith("-v")) {
        System.setProperty("picocli.trace", "INFO");
    }
    CommandLine commandLine = new CommandLine(new CliMain(), new CliPropertiesFactory(apiController));
    commandLine.parseWithHandler(new CommandLine.RunLast(), System.err, args);
    AnsiConsole.systemUninstall();
}
Also used : CommandLine(picocli.CommandLine)

Example 34 with CommandLine

use of picocli.CommandLine in project aion by aionnetwork.

the class EditCli method printUsage.

/**
 * Prints the usage message for this command
 */
public static void printUsage(PrintStream out, EditCli instance) {
    CommandLine parser = new CommandLine(instance);
    String usage = parser.getUsageMessage();
    // the additional dots are added for the styling extra characters
    usage = usage.replaceAll("=....<logger", " <logger");
    out.println(usage);
}
Also used : CommandLine(picocli.CommandLine)

Example 35 with CommandLine

use of picocli.CommandLine in project aion by aionnetwork.

the class CliTest method testFailedParse.

@Test(expected = RuntimeException.class)
@Parameters(method = "parametersForTestFailedParse")
public void testFailedParse(String[] options) {
    Arguments args = new Arguments();
    EditCli editCli = new EditCli();
    CommandLine parser = new CommandLine(args).addSubcommand(editCli);
    parser.parseArgs(options).subcommand();
    editCli.checkOptions();
}
Also used : CommandLine(picocli.CommandLine) Parameters(junitparams.Parameters) Test(org.junit.Test)

Aggregations

CommandLine (picocli.CommandLine)68 Test (org.junit.jupiter.api.Test)22 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)20 Copier (org.neo4j.pushtocloud.PushToCloudCommand.Copier)17 ParseResult (picocli.CommandLine.ParseResult)12 Path (java.nio.file.Path)9 Test (org.junit.Test)9 IOException (java.io.IOException)8 Parameters (junitparams.Parameters)8 CommandSpec (picocli.CommandLine.Model.CommandSpec)6 PrintWriter (java.io.PrintWriter)5 DumpCreator (org.neo4j.pushtocloud.PushToCloudCommand.DumpCreator)5 ParameterException (picocli.CommandLine.ParameterException)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Set (java.util.Set)3 OptionSpec (picocli.CommandLine.Model.OptionSpec)3 InputErrorException (eu.stamp_project.dspot.common.configuration.check.InputErrorException)2 File (java.io.File)2 PrintStream (java.io.PrintStream)2