@Test public void testWithMistypedOption() throws CmdlineOptions.OptionsException { String[] argv = {"-tmid=140", "propfile", "tmfile.xtm"}; setupRDBMS(argv); try { options.parse(); Assert.fail("Incorrect options allowed"); } catch (CmdlineOptions.OptionsException e) { Assert.assertTrue("Wrong problem reported" + e.getArgument(), e.getArgument().equals("-tmid=140")); } }
public void parse() throws OptionsException { Getopt g = new Getopt(application, argv, sargs.toString(), largs.toArray(new LongOpt[] {})); g.setOpterr(false); int c; while ((c = g.getopt()) != -1) { switch (c) { case '?': int ix = g.getOptind(); String option = argv[(ix == 0 ? 0 : ix-1)]; throw new OptionsException(option, g.getOptarg()); default: ListenerIF listener = listeners.get(new Integer(c)); if (listener != null) listener.processOption((char)c, g.getOptarg()); else System.err.println ("Warning: option '" + (char)c + "' ignored"); break; } } for (int i = g.getOptind(); i < argv.length ; i++) { arguments.add(argv[i]); } }
CmdlineOptions { public void parse() throws OptionsException { Getopt g = new Getopt(application, argv, sargs.toString(), largs.toArray(new LongOpt[] {})); g.setOpterr(false); int c; while ((c = g.getopt()) != -1) { switch (c) { case '?': int ix = g.getOptind(); String option = argv[(ix == 0 ? 0 : ix-1)]; throw new OptionsException(option, g.getOptarg()); default: ListenerIF listener = listeners.get(new Integer(c)); if (listener != null) listener.processOption((char)c, g.getOptarg()); else System.err.println ("Warning: option '" + (char)c + "' ignored"); break; } } for (int i = g.getOptind(); i < argv.length ; i++) { arguments.add(argv[i]); } } }
CmdlineOptions { public void parse() throws OptionsException { Getopt g = new Getopt(application, argv, sargs.toString(), largs.toArray(new LongOpt[] {})); g.setOpterr(false); int c; while ((c = g.getopt()) != -1) { switch (c) { case '?': int ix = g.getOptind(); String option = argv[(ix == 0 ? 0 : ix-1)]; throw new OptionsException(option, g.getOptarg()); default: ListenerIF listener = listeners.get(new Integer(c)); if (listener != null) listener.processOption((char)c, g.getOptarg()); else System.err.println ("Warning: option '" + (char)c + "' ignored"); break; } } for (int i = g.getOptind(); i < argv.length ; i++) { arguments.add(argv[i]); } } CmdlineOptions(String application, String[] argv); }
CmdlineOptions { public void parse() throws OptionsException { Getopt g = new Getopt(application, argv, sargs.toString(), largs.toArray(new LongOpt[] {})); g.setOpterr(false); int c; while ((c = g.getopt()) != -1) { switch (c) { case '?': int ix = g.getOptind(); String option = argv[(ix == 0 ? 0 : ix-1)]; throw new OptionsException(option, g.getOptarg()); default: ListenerIF listener = listeners.get(new Integer(c)); if (listener != null) listener.processOption((char)c, g.getOptarg()); else System.err.println ("Warning: option '" + (char)c + "' ignored"); break; } } for (int i = g.getOptind(); i < argv.length ; i++) { arguments.add(argv[i]); } } CmdlineOptions(String application, String[] argv); void addShort(ListenerIF listener, char c); void addShort(ListenerIF listener, char c, boolean req_arg); void addLong(ListenerIF listener, String name, char c); void addLong(ListenerIF listener, String name, char c, boolean req_arg); void parse(); String[] getArguments(); }
CmdlineOptions { public void parse() throws OptionsException { Getopt g = new Getopt(application, argv, sargs.toString(), largs.toArray(new LongOpt[] {})); g.setOpterr(false); int c; while ((c = g.getopt()) != -1) { switch (c) { case '?': int ix = g.getOptind(); String option = argv[(ix == 0 ? 0 : ix-1)]; throw new OptionsException(option, g.getOptarg()); default: ListenerIF listener = listeners.get(new Integer(c)); if (listener != null) listener.processOption((char)c, g.getOptarg()); else System.err.println ("Warning: option '" + (char)c + "' ignored"); break; } } for (int i = g.getOptind(); i < argv.length ; i++) { arguments.add(argv[i]); } } CmdlineOptions(String application, String[] argv); void addShort(ListenerIF listener, char c); void addShort(ListenerIF listener, char c, boolean req_arg); void addLong(ListenerIF listener, String name, char c); void addLong(ListenerIF listener, String name, char c, boolean req_arg); void parse(); String[] getArguments();  }