use of picocli.CommandLine.DefaultExceptionHandler in project hazelcast by hazelcast.
the class HazelcastCommandLine method runCommandLine.
static void runCommandLine(Function<ClientConfig, HazelcastInstance> hzClientFn, PrintStream out, PrintStream err, boolean shouldExit, String[] args) {
CommandLine cmd = new CommandLine(new HazelcastCommandLine(hzClientFn, out, err));
cmd.getSubcommands().get("submit").setStopAtPositional(true);
String version = getBuildInfo().getVersion();
cmd.getCommandSpec().usageMessage().header("Hazelcast " + version);
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);
}
}
}
Aggregations