public static <T> List<T> createFromList(String raw, TypedOption<T> option) { if (raw == null) { return Collections.emptyList(); } final String[] segments = raw.split(option.getListSeparator()); return Arrays.stream(segments).map(s -> create(s.trim(), option)).collect(Collectors.toList()); }
@Test public void testInjectionOfString() throws CLIException { HelloClI command = new HelloClI(); CLI cli = CLIConfigurator.define(HelloClI.class); CommandLine evaluatedCLI = cli.parse(Arrays.asList("--name", "vert.x")); CLIConfigurator.inject(evaluatedCLI, command); assertThat(command.run()).isEqualToIgnoringCase("Hello vert.x"); assertThat(command.name).isEqualToIgnoringCase("vert.x"); }
private CommandLine parse(CLI cli, String... args) throws CLIException { return cli.parse(Arrays.asList(args)); }