@Test public void parseArgumentsAndQuery() { String query = "\"match (n) return n\""; ArrayList<String> strings = new ArrayList<>(); strings.addAll(asList("-a 192.168.1.1 -p 123 --format plain".split(" "))); strings.add(query); assertEquals(Optional.of(query), CliArgHelper.parse(strings.toArray(new String[strings.size()])).getCypher()); }
@Nullable public static CliArgs parse(@Nonnull String... args) { final CliArgs cliArgs = new CliArgs(); final ArgumentParser parser = setupParser(cliArgs.getParameters()); final Namespace ns; try { ns = parser.parseArgs(args); } catch (ArgumentParserException e) { parser.handleError(e); return null; } return getCliArgs( cliArgs, parser, ns ); }
CliArgHelper { @Nullable public static CliArgs parse(@Nonnull String... args) { final CliArgs cliArgs = new CliArgs(); final ArgumentParser parser = setupParser(cliArgs.getParameters()); final Namespace ns; try { ns = parser.parseArgs(args); } catch (ArgumentParserException e) { parser.handleError(e); return null; } return getCliArgs( cliArgs, parser, ns ); } }
CliArgHelper { @Nullable public static CliArgs parse(@Nonnull String... args) { final CliArgs cliArgs = new CliArgs(); final ArgumentParser parser = setupParser(cliArgs.getParameters()); final Namespace ns; try { ns = parser.parseArgs(args); } catch (ArgumentParserException e) { parser.handleError(e); return null; } return getCliArgs( cliArgs, parser, ns ); }  }
CliArgHelper { @Nullable public static CliArgs parse(@Nonnull String... args) { final CliArgs cliArgs = new CliArgs(); final ArgumentParser parser = setupParser(cliArgs.getParameters()); final Namespace ns; try { ns = parser.parseArgs(args); } catch (ArgumentParserException e) { parser.handleError(e); return null; } return getCliArgs( cliArgs, parser, ns ); }  @Nullable static CliArgs parse(@Nonnull String... args); static CliArgs parseAndThrow( @Nonnull String... args ); }
CliArgHelper { @Nullable public static CliArgs parse(@Nonnull String... args) { final CliArgs cliArgs = new CliArgs(); final ArgumentParser parser = setupParser(cliArgs.getParameters()); final Namespace ns; try { ns = parser.parseArgs(args); } catch (ArgumentParserException e) { parser.handleError(e); return null; } return getCliArgs( cliArgs, parser, ns ); }  @Nullable static CliArgs parse(@Nonnull String... args); static CliArgs parseAndThrow( @Nonnull String... args );  }