org.kohsuke.args4j.NamedOptionDef Java Examples

The following examples show how to use org.kohsuke.args4j.NamedOptionDef. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: N4jscOptions.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/** @return array of the goal followed by all options followed by all directory arguments */
public List<String> toArgs() {
	List<String> args = new ArrayList<>();
	args.add(getGoal().name());
	for (N4JSCmdLineParser.ParsedOption po : getDefinedOptions().values()) {
		NamedOptionDef od = po.optionDef;
		String value = po.givenValue;
		args.add(od.name());
		if (value != null) {
			if (value.contains(" ")) {
				value = "\"" + value + "\"";
			}
			args.add(value);
		}
	}
	args.addAll(getDirs().stream().map(f -> f.getAbsolutePath()).collect(Collectors.toList()));

	return args;
}
 
Example #2
Source File: N4JSCmdLineParser.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private void addDefinedOption(OptionDef optionDef, String defaultValue, String givenValue) {
	if (optionDef instanceof NamedOptionDef) {
		NamedOptionDef nod = (NamedOptionDef) optionDef;
		ParsedOption parsedOption = new ParsedOption(nod, defaultValue, givenValue);
		definedOptions.put(nod.name(), parsedOption);
	}
}
 
Example #3
Source File: PartialCmdLineParser.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private OptionHandler<?> findOptionByName(String name) {
	for (OptionHandler<?> h : getOptions()) {
		NamedOptionDef option = (NamedOptionDef) h.option;
		if (name.equals(option.name())) {
			return h;
		}
		for (String alias : option.aliases()) {
			if (name.equals(alias)) {
				return h;
			}
		}
	}
	return null;
}
 
Example #4
Source File: PartialCmdLineParser.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private boolean isHandlerHasHisOptions(NamedOptionDef option,
		Set<OptionHandler<?>> present) {
	for (String depend : option.depends()) {
		if (!present.contains(findOptionHandler(depend)))
			return false;
	}
	return true;
}
 
Example #5
Source File: PartialCmdLineParser.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private boolean isHandlerAllowOtherOptions(NamedOptionDef option,
		Set<OptionHandler<?>> present) {
	for (String forbid : option.forbids()) {
		if (present.contains(findOptionHandler(forbid)))
			return false;
	}
	return true;
}
 
Example #6
Source File: GlobalCliOptions.java    From buck with Apache License 2.0 5 votes vote down vote up
public static boolean isGlobalOption(OptionHandler<?> optionHandler) {
  OptionDef option = optionHandler.option;
  if (option instanceof NamedOptionDef) {
    NamedOptionDef namedOption = (NamedOptionDef) option;
    return GLOBAL_OPTIONS.contains(namedOption.name());
  }
  return false;
}
 
Example #7
Source File: N4JSCmdLineParser.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/** Constructor */
public ParsedOption(NamedOptionDef optionDef, String defaultValue, String givenValue) {
	this.optionDef = optionDef;
	this.defaultValue = defaultValue;
	this.givenValue = givenValue;
}