/** Returns the description of this option, after variables are rendered. Used when generating the usage documentation. * @see Option#description() * @since 3.2 */ public String[] renderedDescription() { String[] desc = description(); if (desc.length == 0) { return desc; } StringBuilder candidates = new StringBuilder(); if (completionCandidates() != null) { for (String c : completionCandidates()) { if (candidates.length() > 0) { candidates.append(", "); } candidates.append(c); } } String defaultValueString = defaultValueString(); String[] result = new String[desc.length]; for (int i = 0; i < desc.length; i++) { result[i] = format(desc[i].replace(DESCRIPTION_VARIABLE_DEFAULT_VALUE, defaultValueString) .replace(DESCRIPTION_VARIABLE_COMPLETION_CANDIDATES, candidates.toString())); } return result; }
private void printArg(ArgSpec arg, PrintWriter pw, String indent) { pw.printf("%sdescription: %s%n", indent, Arrays.toString(arg.description())); pw.printf("%sdescriptionKey: '%s'%n", indent, arg.descriptionKey()); pw.printf("%stypeInfo: %s%n", indent, arg.typeInfo()); pw.printf("%sarity: %s%n", indent, arg.arity()); pw.printf("%ssplitRegex: '%s'%n", indent, arg.splitRegex()); pw.printf("%sinteractive: %s%n", indent, arg.interactive()); pw.printf("%srequired: %s%n", indent, arg.required()); pw.printf("%shidden: %s%n", indent, arg.hidden()); pw.printf("%shideParamSyntax: %s%n", indent, arg.hideParamSyntax()); pw.printf("%sdefaultValue: '%s'%n", indent, arg.defaultValue()); pw.printf("%sshowDefaultValue: %s%n", indent, arg.showDefaultValue()); pw.printf("%shasInitialValue: %s%n", indent, arg.hasInitialValue()); pw.printf("%sinitialValue: '%s'%n", indent, arg.initialValue()); pw.printf("%sparamLabel: '%s'%n", indent, arg.paramLabel()); pw.printf("%sconverters: %s%n", indent, Arrays.toString(arg.converters())); pw.printf("%scompletionCandidates: %s%n", indent, iter(arg.completionCandidates())); pw.printf("%sgetter: %s%n", indent, arg.getter()); pw.printf("%ssetter: %s%n", indent, arg.setter()); }
/** Returns the description of this option, after variables are rendered. Used when generating the usage documentation. * @see Option#description() * @since 3.2 */ public String[] renderedDescription() { String[] desc = description(); if (desc.length == 0) { return desc; } StringBuilder candidates = new StringBuilder(); if (completionCandidates() != null) { for (String c : completionCandidates()) { if (candidates.length() > 0) { candidates.append(", "); } candidates.append(c); } } String defaultValueString = defaultValueString(); String[] result = new String[desc.length]; for (int i = 0; i < desc.length; i++) { result[i] = String.format(desc[i].replace(DESCRIPTION_VARIABLE_DEFAULT_VALUE, defaultValueString) .replace(DESCRIPTION_VARIABLE_COMPLETION_CANDIDATES, candidates.toString())); } return result; }
/** Returns the description template of this option, before variables are {@linkplain Option#description() rendered}. * If a resource bundle has been {@linkplain ArgSpec#messages(Messages) set}, this method will first try to find a value in the resource bundle: * If the resource bundle has no entry for the {@code fully qualified commandName + "." + descriptionKey} or for the unqualified {@code descriptionKey}, * an attempt is made to find the option description using any of the option names (without leading hyphens) as key, * first with the {@code fully qualified commandName + "."} prefix, then without. * @see CommandSpec#qualifiedName(String) * @see Option#description() */ @Override public String[] description() { if (messages() == null) { return super.description(); } String[] newValue = messages().getStringArray(descriptionKey(), null); if (newValue != null) { return newValue; } for (String name : names()) { newValue = messages().getStringArray(CommandSpec.stripPrefix(name), null); if (newValue != null) { return newValue; } } return super.description(); }
/** Returns the description template of this positional parameter, before variables are {@linkplain Parameters#description() rendered}. * If a resource bundle has been {@linkplain ArgSpec#messages(Messages) set}, this method will first try to find a value in the resource bundle: * If the resource bundle has no entry for the {@code fully qualified commandName + "." + descriptionKey} or for the unqualified {@code descriptionKey}, * an attempt is made to find the positional parameter description using {@code paramLabel() + "[" + index() + "]"} as key, * first with the {@code fully qualified commandName + "."} prefix, then without. * @see Parameters#description() * @see CommandSpec#qualifiedName(String) * @since 3.6 */ @Override public String[] description() { if (messages() == null) { return super.description(); } String[] newValue = messages().getStringArray(descriptionKey(), null); if (newValue != null) { return newValue; } newValue = messages().getStringArray(paramLabel() + "[" + index() + "]", null); if (newValue != null) { return newValue; } return super.description(); }
/** Returns the description template of this option, before variables are {@linkplain Option#description() rendered}. * If a resource bundle has been {@linkplain ArgSpec#messages(Messages) set}, this method will first try to find a value in the resource bundle: * If the resource bundle has no entry for the {@code fully qualified commandName + "." + descriptionKey} or for the unqualified {@code descriptionKey}, * an attempt is made to find the option description using any of the option names (without leading hyphens) as key, * first with the {@code fully qualified commandName + "."} prefix, then without. * @see CommandSpec#qualifiedName(String) * @see Option#description() */ @Override public String[] description() { if (messages() == null) { return super.description(); } String[] newValue = messages().getStringArray(descriptionKey(), null); if (newValue != null) { return newValue; } for (String name : names()) { newValue = messages().getStringArray(CommandSpec.stripPrefix(name), null); if (newValue != null) { return newValue; } } return super.description(); }
/** Returns the description template of this positional parameter, before variables are {@linkplain Parameters#description() rendered}. * If a resource bundle has been {@linkplain ArgSpec#messages(Messages) set}, this method will first try to find a value in the resource bundle: * If the resource bundle has no entry for the {@code fully qualified commandName + "." + descriptionKey} or for the unqualified {@code descriptionKey}, * an attempt is made to find the positional parameter description using {@code paramLabel() + "[" + index() + "]"} as key, * first with the {@code fully qualified commandName + "."} prefix, then without. * @see Parameters#description() * @see CommandSpec#qualifiedName(String) * @since 3.6 */ @Override public String[] description() { if (messages() == null) { return super.description(); } String[] newValue = messages().getStringArray(descriptionKey(), null); if (newValue != null) { return newValue; } newValue = messages().getStringArray(paramLabel() + "[" + index() + "]", null); if (newValue != null) { return newValue; } return super.description(); }