Java Code Examples for com.beust.jcommander.ParameterDescription#getDefault()

The following examples show how to use com.beust.jcommander.ParameterDescription#getDefault() . 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: NestableCommand.java    From halyard with Apache License 2.0 6 votes vote down vote up
private void parameterDoc(StringBuilder result, ParameterDescription parameterDescription) {
  result.append(" * `").append(parameterDescription.getNames()).append("`: ");

  Object def = parameterDescription.getDefault();
  if (def != null) {
    result.append("(*Default*: `").append(def.toString()).append("`) ");
  }

  if (parameterDescription.getParameter().required()) {
    result.append("(*Required*) ");
  }

  if (parameterDescription.getParameter().password()) {
    result.append("(*Sensitive data* - user will be prompted on standard input) ");
  }

  result.append(linkify(parameterDescription.getDescription())).append("\n");
}
 
Example 2
Source File: NestableCommand.java    From halyard with Apache License 2.0 6 votes vote down vote up
private static void formatParameter(
    AnsiStoryBuilder story, ParameterDescription parameter, int indentWidth) {
  AnsiParagraphBuilder paragraph = story.addParagraph().setIndentWidth(indentWidth);
  paragraph.addSnippet(parameter.getNames()).addStyle(AnsiStyle.BOLD);

  if (parameter.getDefault() != null) {
    paragraph.addSnippet("=");
    paragraph.addSnippet(parameter.getDefault().toString()).addStyle(AnsiStyle.UNDERLINE);
  }

  if (parameter.getParameter().required()) {
    paragraph.addSnippet(" (required)");
  }

  if (parameter.getParameter().password()) {
    paragraph.addSnippet(" (sensitive data - user will be prompted)");
  }

  paragraph = story.addParagraph().setIndentWidth(indentWidth * 2);
  paragraph.addSnippet(parameter.getDescription());
  story.addNewline();
}
 
Example 3
Source File: Help.java    From parquet-mr with Apache License 2.0 5 votes vote down vote up
private String formatDefault(ParameterDescription param) {
  Object defaultValue = param.getDefault();
  if (defaultValue == null || param.getParameter().arity() < 1) {
    return "";
  }
  return " (default: " + ((defaultValue instanceof String) ?
      "\"" + defaultValue + "\"" :
      defaultValue.toString()) + ")";
}
 
Example 4
Source File: Help.java    From kite with Apache License 2.0 5 votes vote down vote up
private String formatDefault(ParameterDescription param) {
  Object defaultValue = param.getDefault();
  if (defaultValue == null || param.getParameter().arity() < 1) {
    return "";
  }
  return " (default: " + ((defaultValue instanceof String) ?
      "\"" + defaultValue + "\"" :
      defaultValue.toString()) + ")";
}
 
Example 5
Source File: Help.java    From kite with Apache License 2.0 5 votes vote down vote up
private String formatDefault(ParameterDescription param) {
  Object defaultValue = param.getDefault();
  if (defaultValue == null || param.getParameter().arity() < 1) {
    return "";
  }
  return " (default: " + ((defaultValue instanceof String) ?
      "\"" + defaultValue + "\"" :
      defaultValue.toString()) + ")";
}