Method method = candidates.get(0); CommandLine cmd = new CommandLine(method); List<Object> list = cmd.parseWithHandlers(new RunLast().useOut(out).useAnsi(ansi), new DefaultExceptionHandler<List<Object>>().useErr(err).useAnsi(ansi), args); return list == null ? null : list.get(0);
List<Object> results = cmd.parseWithHandlers(new RunLast().useOut(out).useAnsi(ansi), new DefaultExceptionHandler<List<Object>>().useErr(err).useAnsi(ansi), args); @SuppressWarnings("unchecked") T result = (results == null || results.isEmpty()) ? null : (T) results.get(0); return result;
List<Object> results = cmd.parseWithHandlers(new RunLast().useOut(out).useAnsi(ansi), new DefaultExceptionHandler<List<Object>>().useErr(err).useAnsi(ansi), args); @SuppressWarnings("unchecked") T result = (results == null || results.isEmpty()) ? null : (T) results.get(0); return result;
List<Object> results = cmd.parseWithHandlers(new RunLast().useOut(out).useAnsi(ansi), new DefaultExceptionHandler<List<Object>>().useErr(err).useAnsi(ansi), args); @SuppressWarnings("unchecked") T result = (results == null || results.isEmpty()) ? null : (T) results.get(0); return result;
List<Object> results = cmd.parseWithHandlers(new RunLast().useOut(out).useAnsi(ansi), new DefaultExceptionHandler<List<Object>>().useErr(err).useAnsi(ansi), args); @SuppressWarnings("unchecked") T result = (results == null || results.isEmpty()) ? null : (T) results.get(0); return result;
cmd.parseWithHandlers(new RunLast().useOut(out).useAnsi(ansi), new DefaultExceptionHandler<List<Object>>().useErr(err).useAnsi(ansi), args);
cmd.parseWithHandlers(new RunLast().useOut(out).useAnsi(ansi), new DefaultExceptionHandler<List<Object>>().useErr(err).useAnsi(ansi), args);
Method method = candidates.get(0); CommandLine cmd = new CommandLine(method); List<Object> list = cmd.parseWithHandlers(new RunLast().useOut(out).useAnsi(ansi), new DefaultExceptionHandler<List<Object>>().useErr(err).useAnsi(ansi), args); return list == null ? null : list.get(0);
static void runCommandLine( Function<ClientConfig, JetInstance> jetClientFn, PrintStream out, PrintStream err, boolean shouldExit, String[] args ) { CommandLine cmd = new CommandLine(new JetCommandLine(jetClientFn, out, err)); if (args.length == 0) { cmd.usage(out); } else { DefaultExceptionHandler<List<Object>> excHandler = new ExceptionHandler<List<Object>>().useErr(err).useAnsi(Ansi.AUTO); if (shouldExit) { excHandler.andExit(1); } List<Object> parsed = cmd.parseWithHandlers(new RunAll().useOut(out).useAnsi(Ansi.AUTO), excHandler, args); // only top command was executed if (parsed != null && parsed.size() == 1) { cmd.usage(out); } } }
CommandLine.Model.CommandSpec parseCommand(final String... args) { final TestPantheonCommand pantheonCommand = new TestPantheonCommand( mockLogger, mockBlockImporter, mockRunnerBuilder, mockControllerBuilder, mockSyncConfBuilder); // parse using Ansi.OFF to be able to assert on non formatted output results pantheonCommand.parse( new RunLast().useOut(outPrintStream).useAnsi(Ansi.OFF), new DefaultExceptionHandler<List<Object>>().useErr(errPrintStream).useAnsi(Ansi.OFF), args); return pantheonCommand.spec; }
public static Optional<ExitCode> parse(final String... args) { final CommandLine cli = new CommandLine(new Cli()); final List<?> o = cli.parseWithHandlers(new CommandLine.RunLast().useAnsi(CommandLine.Help.Ansi.ON), CommandLine.defaultExceptionHandler() .useAnsi(CommandLine.Help.Ansi.OFF), args); if (o == null) { return Optional.of(ExitCode.NO_OPERATION); } else { return Optional.ofNullable((ExitCode) o.get(0)); } }
public static Optional<ExitCode> parse(final String... args) { final CommandLine cli = new CommandLine(new Cli()); final List<?> o = cli.parseWithHandlers(new CommandLine.RunLast().useAnsi(CommandLine.Help.Ansi.ON), CommandLine.defaultExceptionHandler() .useAnsi(CommandLine.Help.Ansi.OFF), args); if (o == null) { return Optional.of(ExitCode.NO_OPERATION); } else { return Optional.ofNullable((ExitCode) o.get(0)); } }
cmd.parseWithHandlers(new RunLast().useOut(out).useAnsi(ansi), new DefaultExceptionHandler<List<Object>>().useErr(err).useAnsi(ansi), args);
cmd.parseWithHandlers(new RunLast().useOut(out).useAnsi(ansi), new DefaultExceptionHandler<List<Object>>().useErr(err).useAnsi(ansi), args);