private String getOptionName() { return currentOptionHandler.option.toString(); }
private String getOptionName() { return currentOptionHandler.option.toString(); }
protected int fallback(String subCmd) throws CmdLineException { throw new CmdLineException(owner, Messages.ILLEGAL_OPERAND, option.toString(), subCmd); }
protected int fallback(String subCmd) throws CmdLineException { throw new CmdLineException(owner, Messages.ILLEGAL_OPERAND, option.toString(), subCmd); }
/** * Get string representing usage for this option, of the form "name metaval" or "name=metaval, * e.g. "--foo VALUE" or "--foo=VALUE" * @param rb ResourceBundle to get localized version of meta string * @param properties * Affects the formatting behaviours. */ public final String getNameAndMeta(ResourceBundle rb, ParserProperties properties) { String str = option.isArgument() ? "" : option.toString(); String meta = getMetaVariable(rb); if (meta != null) { if (str.length() > 0) { str += properties.getOptionValueDelimiter(); } str += meta; } return str; }
@Override public int parseArguments(Parameters params) throws CmdLineException { String s = params.getParameter(0); Pattern p; try { p = Pattern.compile(s); } catch (PatternSyntaxException x) { throw new CmdLineException(owner, Messages.ILLEGAL_PATTERN.format(option.toString(), s)); } setter.addValue(p); return 1; }
/** * Get string representing usage for this option, of the form "name metaval" or "name=metaval, * e.g. "--foo VALUE" or "--foo=VALUE" * @param rb ResourceBundle to get localized version of meta string * @param properties * Affects the formatting behaviours. */ public final String getNameAndMeta(ResourceBundle rb, ParserProperties properties) { String str = option.isArgument() ? "" : option.toString(); String meta = getMetaVariable(rb); if (meta != null) { if (str.length() > 0) { str += properties.getOptionValueDelimiter(); } str += meta; } return str; }
@Override public int parseArguments(Parameters params) throws CmdLineException { String s = params.getParameter(0).replaceAll("-", "_"); T value = null; for( T o : enumType.getEnumConstants() ) if(o.name().equalsIgnoreCase(s)) { value = o; break; } if(value==null) { if (option.isArgument()) { throw new CmdLineException(owner, Messages.ILLEGAL_OPERAND, option.toString(), s); } else { throw new CmdLineException(owner, Messages.ILLEGAL_OPERAND, params.getParameter(-1),s); } } setter.addValue(value); return 1; }
@Override public int parseArguments(Parameters params) throws CmdLineException { String s = params.getParameter(0); Pattern p; try { p = Pattern.compile(s); } catch (PatternSyntaxException x) { throw new CmdLineException(owner, Messages.ILLEGAL_PATTERN.format(option.toString(), s)); } setter.addValue(p); return 1; }
private void checkRequiredOptionsAndArguments(Set<OptionHandler> present) throws CmdLineException { // make sure that all mandatory options are present for (OptionHandler handler : options) { if(handler.option.required() && !present.contains(handler)) { throw new CmdLineException(this, Messages.REQUIRED_OPTION_MISSING, handler.option.toString()); } } // make sure that all mandatory arguments are present for (OptionHandler handler : arguments) { if(handler.option.required() && !present.contains(handler)) { throw new CmdLineException(this, Messages.REQUIRED_ARGUMENT_MISSING, handler.option.toString()); } } //make sure that all requires arguments are present for (OptionHandler handler : present) { if (handler.option instanceof NamedOptionDef && !isHandlerHasHisOptions((NamedOptionDef)handler.option, present)) { throw new CmdLineException(this, Messages.REQUIRES_OPTION_MISSING, handler.option.toString(), Arrays.toString(((NamedOptionDef)handler.option).depends())); } } //make sure that all forbids arguments are not present for (OptionHandler handler : present) { if (handler.option instanceof NamedOptionDef && !isHandlerAllowOtherOptions((NamedOptionDef) handler.option, present)) { throw new CmdLineException(this, Messages.FORBIDDEN_OPTION_PRESENT, handler.option.toString(), Arrays.toString(((NamedOptionDef) handler.option).forbids())); } } }
private void checkRequiredOptionsAndArguments(Set<OptionHandler> present) throws CmdLineException { // make sure that all mandatory options are present for (OptionHandler handler : options) { if(handler.option.required() && !present.contains(handler)) { throw new CmdLineException(this, Messages.REQUIRED_OPTION_MISSING, handler.option.toString()); } } // make sure that all mandatory arguments are present for (OptionHandler handler : arguments) { if(handler.option.required() && !present.contains(handler)) { throw new CmdLineException(this, Messages.REQUIRED_ARGUMENT_MISSING, handler.option.toString()); } } //make sure that all requires arguments are present for (OptionHandler handler : present) { if (handler.option instanceof NamedOptionDef && !isHandlerHasHisOptions((NamedOptionDef)handler.option, present)) { throw new CmdLineException(this, Messages.REQUIRES_OPTION_MISSING, handler.option.toString(), Arrays.toString(((NamedOptionDef)handler.option).depends())); } } //make sure that all forbids arguments are not present for (OptionHandler handler : present) { if (handler.option instanceof NamedOptionDef && !isHandlerAllowOtherOptions((NamedOptionDef) handler.option, present)) { throw new CmdLineException(this, Messages.FORBIDDEN_OPTION_PRESENT, handler.option.toString(), Arrays.toString(((NamedOptionDef) handler.option).forbids())); } } }
@Override public int parseArguments(Parameters params) throws CmdLineException { String s = params.getParameter(0).replaceAll("-", "_"); T value = null; for( T o : enumType.getEnumConstants() ) if(o.name().equalsIgnoreCase(s)) { value = o; break; } if(value==null) { if (option.isArgument()) { throw new CmdLineException(owner, Messages.ILLEGAL_OPERAND, option.toString(), s); } else { throw new CmdLineException(owner, Messages.ILLEGAL_OPERAND, params.getParameter(-1),s); } } setter.addValue(value); return 1; }
private String getOptionName() { return currentOptionHandler.option.toString(); } }
@Override public int parseArguments(Parameters params) throws CmdLineException { String s = params.getParameter(0); Pattern p; try { p = Pattern.compile(s); } catch (PatternSyntaxException x) { throw new CmdLineException(owner, Messages.ILLEGAL_PATTERN.format(option.toString(), s)); } setter.addValue(p); return 1; }