本文整理汇总了Java中com.beust.jcommander.Parameter类的典型用法代码示例。如果您正苦于以下问题:Java Parameter类的具体用法?Java Parameter怎么用?Java Parameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Parameter类属于com.beust.jcommander包,在下文中一共展示了Parameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getParameterBaseConverter
import com.beust.jcommander.Parameter; //导入依赖的package包/类
private static GeoWaveBaseConverter<?> getParameterBaseConverter(
Parameter parameter ) {
GeoWaveBaseConverter<?> converter = null;
try {
Constructor<?> ctor = parameter.converter().getConstructor(
String.class);
if (ctor != null) {
converter = (GeoWaveBaseConverter<?>) ctor.newInstance(new Object[] {
""
});
}
}
catch (Exception e) {
LOGGER.error(
"An error occurred getting converter from parameter: " + e.getLocalizedMessage(),
e);
}
return converter;
}
示例2: getConverterInstance
import com.beust.jcommander.Parameter; //导入依赖的package包/类
@Override
public IStringConverter<?> getConverterInstance(Parameter parameter, Class<?> forType, String optionName) {
if (Path.class.equals(forType)) {
return new CustomPathConverter();
}
return null;
}
示例3: appendPullRequestsCommentArguments
import com.beust.jcommander.Parameter; //导入依赖的package包/类
private void appendPullRequestsCommentArguments(StringBuilder builder, List<Field> fields, boolean namedArguments) {
for (Field field : fields) {
Parameter parameter = field.getAnnotation(Parameter.class);
String[] names = parameter.names();
if (names.length > 0) {
String name = names[0];
if (!namedArguments) {
continue;
}
builder.append(" ");
builder.append(name);
} else {
if (namedArguments) {
continue;
}
}
Object value = getFieldValue(field, this);
if (value != null) {
builder.append(" ");
if (value instanceof Collection) {
builder.append(Strings.join((Collection) value, " "));
} else if (value instanceof Object[]) {
builder.append(Strings.join(" ", (Object[]) value));
} else {
builder.append(value);
}
}
}
}
示例4: generateFlagsInfo
import com.beust.jcommander.Parameter; //导入依赖的package包/类
private CharSequence generateFlagsInfo(Element classElement) throws ElementException {
StringBuilder sb = new StringBuilder();
AnnotationHelper<UsesFlags> annotation = annotationHelper(classElement, UsesFlags.class);
if (annotation == null) {
return sb;
}
StringBuilder flagsString = new StringBuilder();
for (DeclaredType flag : annotation.getClassListValue("value")) {
Element flagClass = flag.asElement();
for (Element member : flagClass.getEnclosedElements()) {
Parameter flagAnnotation = member.getAnnotation(Parameter.class);
if (flagAnnotation == null
|| !(member instanceof VariableElement)
|| flagAnnotation.hidden()) {
continue;
}
VariableElement field = (VariableElement) member;
flagsString.append(Joiner.on(", ").join(flagAnnotation.names()));
flagsString.append(" | *");
flagsString.append(simplerJavaTypes(field));
flagsString.append("* | ");
flagsString.append(flagAnnotation.description());
flagsString.append("\n");
}
}
if (flagsString.length() > 0) {
sb.append("\n\n**Command line flags:**\n\n");
sb.append("Name | Type | Description\n");
sb.append("---- | ----------- | -----------\n");
sb.append(flagsString);
sb.append("\n");
}
return sb;
}
示例5: setLog
import com.beust.jcommander.Parameter; //导入依赖的package包/类
@Parameter(
names = {"-l", "--log"},
converter = LogLevelConverter.class,
description = "Set the log level of the CLI."
)
public void setLog(Level log) {
GlobalOptions.getGlobalOptions().setLog(log);
}
示例6: setTestcaseId
import com.beust.jcommander.Parameter; //导入依赖的package包/类
@Override
@Parameter(names = { "-c", "--testcase" }, arity = 1,
description =
"Test case for running conformance against test data. Possible values: [testcase0, testcase1a, testcase1b, testcase2, testcase3, testcase4]")
public void setTestcaseId(String testcaseId) {
this.testcaseId = testcaseId;
}
示例7: ParameterRestFieldValue
import com.beust.jcommander.Parameter; //导入依赖的package包/类
public ParameterRestFieldValue(
final Field field,
final Parameter parameter,
final Object instance ) {
super(
field,
parameter);
this.instance = instance;
}
示例8: printConfig
import com.beust.jcommander.Parameter; //导入依赖的package包/类
private static void printConfig(Class configClass) throws IllegalAccessException, InstantiationException {
Field[] fields = configClass.getDeclaredFields();
System.out.println();
System.out.println("### " + configClass.getSimpleName());
System.out.println();
Object defaultConfig = configClass.newInstance();
System.out.println("|Name|Default|Description|");
System.out.println("|---|---|---|");
try {
for (Field field : fields) {
field.setAccessible(true);
StringBuilder sb = new StringBuilder();
sb.append("|");
Parameter param = field.getDeclaredAnnotation(Parameter.class);
if (param != null) {
String names = Stream.of(param.names())
.collect(Collectors.joining(", "));
// name
sb.append(names).append("|");
// default
sb.append(param.required() ? "**required**" : field.get(defaultConfig) + " ").append("|");
// description
sb.append(param.description()).append("|");
System.out.println(sb.toString());
}
ParametersDelegate delegate = field.getDeclaredAnnotation(ParametersDelegate.class);
if (delegate != null) {
printConfig(field.getType());
}
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
示例9: appendPullRequestCommentArguments
import com.beust.jcommander.Parameter; //导入依赖的package包/类
/**
* Appends any command specific parameters
*/
protected void appendPullRequestCommentArguments(StringBuilder builder) {
List<Field> fields = findFieldsAnnotatedWith(getClass(), Parameter.class);
appendPullRequestsCommentArguments(builder, fields, true);
appendPullRequestsCommentArguments(builder, fields, false);
}
示例10: setOutput
import com.beust.jcommander.Parameter; //导入依赖的package包/类
@Parameter(names = { "-o", "--output" }, converter = FormatConverter.class, help = true, description = "Format the CLIs output.")
public void setOutput(AnsiFormatUtils.Format output) {
GlobalOptions.getGlobalOptions().setOutput(output);
}
示例11: setDebug
import com.beust.jcommander.Parameter; //导入依赖的package包/类
@Parameter(names = {"-d", "--debug"}, description = "Show detailed network traffic with halyard daemon.")
public void setDebug(boolean debug) {
GlobalOptions.getGlobalOptions().setDebug(debug);
}
示例12: setAlpha
import com.beust.jcommander.Parameter; //导入依赖的package包/类
@Parameter(names = {"-a", "--alpha"}, description = "Enable alpha halyard features.")
public void setAlpha(boolean alpha) {
GlobalOptions.getGlobalOptions().setAlpha(alpha);
}
示例13: setQuiet
import com.beust.jcommander.Parameter; //导入依赖的package包/类
@Parameter(names = {"-q", "--quiet"}, description = "Show no task information or messages. When set, ANSI formatting will be disabled, and all prompts will be accepted.")
public void setQuiet(boolean quiet) {
GlobalOptions.getGlobalOptions().setQuiet(quiet);
GlobalOptions.getGlobalOptions().setColor(!quiet);
}
示例14: setColor
import com.beust.jcommander.Parameter; //导入依赖的package包/类
@Parameter(names = { "-c", "--color" }, description = "Enable terminal color output.", arity = 1)
public void setColor(boolean color) {
GlobalOptions.getGlobalOptions().setColor(color);
}
示例15: setDaemonEndpoint
import com.beust.jcommander.Parameter; //导入依赖的package包/类
@Parameter(names = { "--daemon-endpoint"}, description = "If supplied, connect to the daemon at this address.")
public void setDaemonEndpoint(String address) {
GlobalOptions.getGlobalOptions().setDaemonEndpoint(address);
}