本文整理匯總了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);
}