@Test public void nonsenseArgsGiveError() { ByteArrayOutputStream bout = new ByteArrayOutputStream(); System.setErr(new PrintStream(bout)); CliArgs cliargs = CliArgHelper.parse("-notreally"); assertNull(cliargs); assertTrue(bout.toString().contains("cypher-shell [-h]")); assertTrue(bout.toString().contains("cypher-shell: error: unrecognized arguments: '-notreally'")); }
@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 );  }