public static GalenActionConfigArguments parse(String[] args) { args = ArgumentsUtils.processSystemProperties(args); Options options = new Options(); options.addOption("g", "global", false, "Flag to create global config in user home directory"); CommandLineParser parser = new PosixParser(); CommandLine cmd; try { cmd = parser.parse(options, args); } catch (MissingArgumentException e) { throw new IllegalArgumentException("Missing value for " + e.getOption().getLongOpt(), e); } catch (Exception ex) { throw new RuntimeException(ex); } GalenActionConfigArguments configArguments = new GalenActionConfigArguments(); configArguments.isGlobal = cmd.hasOption("g"); return configArguments; }
public static GalenActionGenerateArguments parse(String[] args) { args = ArgumentsUtils.processSystemProperties(args); Options options = new Options(); options.addOption("e", "export", true, "Path to generated spec file"); options.addOption("G", "no-galen-extras", false, "Disable galen-extras expressions"); CommandLineParser parser = new PosixParser(); CommandLine cmd; try { cmd = parser.parse(options, args); } catch (MissingArgumentException e) { throw new IllegalArgumentException("Missing value for " + e.getOption().getLongOpt(), e); } catch (Exception ex) { throw new RuntimeException(ex); } GalenActionGenerateArguments arguments = new GalenActionGenerateArguments(); arguments.setExport(cmd.getOptionValue("e")); arguments.setUseGalenExtras(!cmd.hasOption("G")); if (cmd.getArgs() == null || cmd.getArgs().length < 1) { throw new IllegalArgumentException("Missing page dump file"); } arguments.setPath(cmd.getArgs()[0]); return arguments; }
public static GalenActionDumpArguments parse(String[] args) { args = ArgumentsUtils.processSystemProperties(args); Options options = new Options(); options.addOption("u", "url", true, "Initial test url"); options.addOption("s", "size", true, "Browser window size"); options.addOption("W", "max-width", true, "Maximum width of element area image"); options.addOption("H", "max-height", true, "Maximum height of element area image"); options.addOption("E", "export", true, "Export path for page dump"); options.addOption("c", "config", true, "Path to config"); CommandLineParser parser = new PosixParser(); CommandLine cmd; try { cmd = parser.parse(options, args); } catch (MissingArgumentException e) { throw new IllegalArgumentException("Missing value for " + e.getOption().getLongOpt(), e); } catch (Exception ex) { throw new RuntimeException(ex); } GalenActionDumpArguments arguments = new GalenActionDumpArguments(); arguments.setUrl(cmd.getOptionValue("u")); arguments.setScreenSize(convertScreenSize(cmd.getOptionValue("s"))); arguments.setMaxWidth(parseOptionalInt(cmd.getOptionValue("W"))); arguments.setMaxHeight(parseOptionalInt(cmd.getOptionValue("H"))); arguments.setExport(cmd.getOptionValue("E")); arguments.setPaths(asList(cmd.getArgs())); arguments.setConfig(cmd.getOptionValue("c")); return arguments; }
cmd = parser.parse(options, args); } catch (MissingArgumentException e) { throw new IllegalArgumentException("Missing value for " + e.getOption().getLongOpt(), e); } catch (Exception ex) { throw new RuntimeException(ex);
@Test public void testDoubleDash2() throws Exception { Options options = new Options(); options.addOption(OptionBuilder.hasArg().create('n')); options.addOption(OptionBuilder.create('m')); try { parser.parse(options, new String[]{"-n", "--", "-m"}); fail("MissingArgumentException not thrown for option -n"); } catch (MissingArgumentException e) { assertNotNull("option null", e.getOption()); assertEquals("n", e.getOption().getOpt()); } }
cmd = parser.parse(options, args); } catch (MissingArgumentException e) { throw new IllegalArgumentException("Missing value for " + e.getOption().getLongOpt(), e); } catch (Exception ex) { throw new RuntimeException(ex);
cmd = parser.parse(options, args); } catch (MissingArgumentException e) { throw new IllegalArgumentException("Missing value for " + e.getOption().getLongOpt(), e); } catch (Exception ex) { throw new RuntimeException(ex);
@Test public void testLackOfError() throws Exception { String[] args = new String[] { "-k", "-a", "Caesar" }; try { parser.parse( options, args); fail("MissingArgumentException expected"); } catch(MissingArgumentException e) { assertEquals("option missing an argument", "k", e.getOption().getOpt()); } }
@Test public void testMissingArg() throws Exception { String[] args = new String[] { "-b" }; boolean caught = false; try { parser.parse(options, args); } catch (MissingArgumentException e) { caught = true; assertEquals("option missing an argument", "b", e.getOption().getOpt()); } assertTrue( "Confirm MissingArgumentException caught", caught ); }
@Test public void testMissingArgWithBursting() throws Exception { String[] args = new String[] { "-acb" }; boolean caught = false; try { parser.parse(options, args); } catch (MissingArgumentException e) { caught = true; assertEquals("option missing an argument", "b", e.getOption().getOpt()); } assertTrue( "Confirm MissingArgumentException caught", caught ); }
public static GalenActionConfigArguments parse(String[] args) { args = ArgumentsUtils.processSystemProperties(args); Options options = new Options(); options.addOption("g", "global", false, "Flag to create global config in user home directory"); CommandLineParser parser = new PosixParser(); CommandLine cmd; try { cmd = parser.parse(options, args); } catch (MissingArgumentException e) { throw new IllegalArgumentException("Missing value for " + e.getOption().getLongOpt(), e); } catch (Exception ex) { throw new RuntimeException(ex); } GalenActionConfigArguments configArguments = new GalenActionConfigArguments(); configArguments.isGlobal = cmd.hasOption("g"); return configArguments; }
public static GalenActionGenerateArguments parse(String[] args) { args = ArgumentsUtils.processSystemProperties(args); Options options = new Options(); options.addOption("e", "export", true, "Path to generated spec file"); options.addOption("G", "no-galen-extras", false, "Disable galen-extras expressions"); CommandLineParser parser = new PosixParser(); CommandLine cmd; try { cmd = parser.parse(options, args); } catch (MissingArgumentException e) { throw new IllegalArgumentException("Missing value for " + e.getOption().getLongOpt(), e); } catch (Exception ex) { throw new RuntimeException(ex); } GalenActionGenerateArguments arguments = new GalenActionGenerateArguments(); arguments.setExport(cmd.getOptionValue("e")); arguments.setUseGalenExtras(!cmd.hasOption("G")); if (cmd.getArgs() == null || cmd.getArgs().length < 1) { throw new IllegalArgumentException("Missing page dump file"); } arguments.setPath(cmd.getArgs()[0]); return arguments; }
public static GalenActionDumpArguments parse(String[] args) { args = ArgumentsUtils.processSystemProperties(args); Options options = new Options(); options.addOption("u", "url", true, "Initial test url"); options.addOption("s", "size", true, "Browser window size"); options.addOption("W", "max-width", true, "Maximum width of element area image"); options.addOption("H", "max-height", true, "Maximum height of element area image"); options.addOption("E", "export", true, "Export path for page dump"); options.addOption("c", "config", true, "Path to config"); CommandLineParser parser = new PosixParser(); CommandLine cmd; try { cmd = parser.parse(options, args); } catch (MissingArgumentException e) { throw new IllegalArgumentException("Missing value for " + e.getOption().getLongOpt(), e); } catch (Exception ex) { throw new RuntimeException(ex); } GalenActionDumpArguments arguments = new GalenActionDumpArguments(); arguments.setUrl(cmd.getOptionValue("u")); arguments.setScreenSize(convertScreenSize(cmd.getOptionValue("s"))); arguments.setMaxWidth(parseOptionalInt(cmd.getOptionValue("W"))); arguments.setMaxHeight(parseOptionalInt(cmd.getOptionValue("H"))); arguments.setExport(cmd.getOptionValue("E")); arguments.setPaths(asList(cmd.getArgs())); arguments.setConfig(cmd.getOptionValue("c")); return arguments; }
cmd = parser.parse(options, args); } catch (MissingArgumentException e) { throw new IllegalArgumentException("Missing value for " + e.getOption().getLongOpt(), e); } catch (Exception ex) { throw new RuntimeException(ex);
cmd = parser.parse(options, args); } catch (MissingArgumentException e) { throw new IllegalArgumentException("Missing value for " + e.getOption().getLongOpt(), e); } catch (Exception ex) { throw new RuntimeException(ex);
throw new CommandBadArgumentNumberException(this, e); } catch (final MissingArgumentException e) { throw new CommandMissingArgumentException(this, e.getOption(), e); } catch (final MissingOptionException e) { throw new CommandMissingOptionsException(this, e.getMissingOptions(), e);
throw new CommandBadArgumentNumberException(this, e); } catch (final MissingArgumentException e) { throw new CommandMissingArgumentException(this, e.getOption(), e); } catch (final MissingOptionException e) { throw new CommandMissingOptionsException(this, e.getMissingOptions(), e);
throw new CommandBadArgumentNumberException(this, e); } catch (final MissingArgumentException e) { throw new CommandMissingArgumentException(this, e.getOption(), e); } catch (final MissingOptionException e) { throw new CommandMissingOptionsException(this, e.getMissingOptions(), e);
throw new CommandBadArgumentNumberException(this, e); } catch (final MissingArgumentException e) { throw new CommandMissingArgumentException(this, e.getOption(), e); } catch (final MissingOptionException e) { throw new CommandMissingOptionsException(this, e.getMissingOptions(), e);
throw new CommandBadArgumentNumberException(this, e); } catch (final MissingArgumentException e) { throw new CommandMissingArgumentException(this, e.getOption(), e); } catch (final MissingOptionException e) { throw new CommandMissingOptionsException(this, e.getMissingOptions(), e);