@Test(expected = SoarException.class) public void testUnknownLongOption() throws SoarException { op.process(Lists.newArrayList("command", "--alpha")); }
public List<String> process(List<String> args) throws SoarException { arguments = new HashMap<String, String>(); List<String> nonOptionArgs = new ArrayList<String>(); if (args.isEmpty()) return nonOptionArgs; Iterator<String> iter = args.iterator(); iter.next(); boolean done = false; while (iter.hasNext()) { String arg = iter.next(); if (!done && arg.length() > 1 && arg.charAt(0) == '-') { if (arg.charAt(1) == '-') { if (arg.length() == 2) { done = true; } else { Option<E> option = resolveLongOption(arg.substring(2)); if (option == null) throw new SoarException("Unknown option: " + arg); processOption(option, arg, iter); } continue; } else { if (!isNumber(arg)) { for (int i = 1; i < arg.length(); ++i) { Option<E> option = resolveShortOption(arg.charAt(i)); if (option == null) throw new SoarException("Unknown option: " + arg); boolean consumedArg = processOption(option, arg, iter, i); if (consumedArg) break; } continue; } } } nonOptionArgs.add(arg); } return nonOptionArgs; }
OptionProcessor { public List<String> process(List<String> args) throws SoarException { arguments = new HashMap<String, String>(); List<String> nonOptionArgs = new ArrayList<String>(); if (args.isEmpty()) return nonOptionArgs; Iterator<String> iter = args.iterator(); iter.next(); boolean done = false; while (iter.hasNext()) { String arg = iter.next(); if (!done && arg.length() > 1 && arg.charAt(0) == '-') { if (arg.charAt(1) == '-') { if (arg.length() == 2) { done = true; } else { Option<E> option = resolveLongOption(arg.substring(2)); if (option == null) throw new SoarException("Unknown option: " + arg); processOption(option, arg, iter); } continue; } else { if (!isNumber(arg)) { for (int i = 1; i < arg.length(); ++i) { Option<E> option = resolveShortOption(arg.charAt(i)); if (option == null) throw new SoarException("Unknown option: " + arg); boolean consumedArg = processOption(option, arg, iter, i); if (consumedArg) break; } continue; } } } nonOptionArgs.add(arg); } return nonOptionArgs; } }
OptionProcessor { public List<String> process(List<String> args) throws SoarException { arguments = new HashMap<String, String>(); List<String> nonOptionArgs = new ArrayList<String>(); if (args.isEmpty()) return nonOptionArgs; Iterator<String> iter = args.iterator(); iter.next(); boolean done = false; while (iter.hasNext()) { String arg = iter.next(); if (!done && arg.length() > 1 && arg.charAt(0) == '-') { if (arg.charAt(1) == '-') { if (arg.length() == 2) { done = true; } else { Option<E> option = resolveLongOption(arg.substring(2)); if (option == null) throw new SoarException("Unknown option: " + arg); processOption(option, arg, iter); } continue; } else { if (!isNumber(arg)) { for (int i = 1; i < arg.length(); ++i) { Option<E> option = resolveShortOption(arg.charAt(i)); if (option == null) throw new SoarException("Unknown option: " + arg); boolean consumedArg = processOption(option, arg, iter, i); if (consumedArg) break; } continue; } } } nonOptionArgs.add(arg); } return nonOptionArgs; }  }
OptionProcessor { public List<String> process(List<String> args) throws SoarException { arguments = new HashMap<String, String>(); List<String> nonOptionArgs = new ArrayList<String>(); if (args.isEmpty()) return nonOptionArgs; Iterator<String> iter = args.iterator(); iter.next(); boolean done = false; while (iter.hasNext()) { String arg = iter.next(); if (!done && arg.length() > 1 && arg.charAt(0) == '-') { if (arg.charAt(1) == '-') { if (arg.length() == 2) { done = true; } else { Option<E> option = resolveLongOption(arg.substring(2)); if (option == null) throw new SoarException("Unknown option: " + arg); processOption(option, arg, iter); } continue; } else { if (!isNumber(arg)) { for (int i = 1; i < arg.length(); ++i) { Option<E> option = resolveShortOption(arg.charAt(i)); if (option == null) throw new SoarException("Unknown option: " + arg); boolean consumedArg = processOption(option, arg, iter, i); if (consumedArg) break; } continue; } } } nonOptionArgs.add(arg); } return nonOptionArgs; }  static OptionProcessor<T> create(); OptionBuilder newOption(E longOption); List<String> process(List<String> args); boolean has(E longOption); void set(E longOption); void unset(E longOption); void set(E longOption, String argument); String get(E longOption); int getInteger(E longOption); double getDouble(E longOption); float getFloat(E longOption); @Override String toString(); }
OptionProcessor { public List<String> process(List<String> args) throws SoarException { arguments = new HashMap<String, String>(); List<String> nonOptionArgs = new ArrayList<String>(); if (args.isEmpty()) return nonOptionArgs; Iterator<String> iter = args.iterator(); iter.next(); boolean done = false; while (iter.hasNext()) { String arg = iter.next(); if (!done && arg.length() > 1 && arg.charAt(0) == '-') { if (arg.charAt(1) == '-') { if (arg.length() == 2) { done = true; } else { Option<E> option = resolveLongOption(arg.substring(2)); if (option == null) throw new SoarException("Unknown option: " + arg); processOption(option, arg, iter); } continue; } else { if (!isNumber(arg)) { for (int i = 1; i < arg.length(); ++i) { Option<E> option = resolveShortOption(arg.charAt(i)); if (option == null) throw new SoarException("Unknown option: " + arg); boolean consumedArg = processOption(option, arg, iter, i); if (consumedArg) break; } continue; } } } nonOptionArgs.add(arg); } return nonOptionArgs; }  static OptionProcessor<T> create(); OptionBuilder newOption(E longOption); List<String> process(List<String> args); boolean has(E longOption); void set(E longOption); void unset(E longOption); void set(E longOption, String argument); String get(E longOption); int getInteger(E longOption); double getDouble(E longOption); float getFloat(E longOption); @Override String toString();  }