/** 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 static void addTrailingDefaultLine(List<Text[]> result, ArgSpec arg, ColorScheme scheme) { Text EMPTY = Ansi.EMPTY_TEXT; result.add(new Text[]{EMPTY, EMPTY, EMPTY, EMPTY, scheme.ansi().new Text(" Default: " + arg.defaultValueString())}); }
private static Text[] createDescriptionFirstLines(ColorScheme scheme, ArgSpec arg, String[] description, boolean[] showDefault) { Text[] result = scheme.ansi().new Text(str(description, 0)).splitLines(); if (result.length == 0 || (result.length == 1 && result[0].plain.length() == 0)) { if (showDefault[0]) { result = new Text[]{scheme.ansi().new Text(" Default: " + arg.defaultValueString())}; showDefault[0] = false; // don't show the default value twice } else { result = new Text[]{ Ansi.EMPTY_TEXT }; } } return result; }
/** 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; }
private static void addTrailingDefaultLine(List<Text[]> result, ArgSpec arg, ColorScheme scheme) { Text EMPTY = Ansi.EMPTY_TEXT; result.add(new Text[]{EMPTY, EMPTY, EMPTY, EMPTY, scheme.ansi().new Text(" Default: " + arg.defaultValueString())}); }
private static Text[] createDescriptionFirstLines(ColorScheme scheme, ArgSpec arg, String[] description, boolean[] showDefault) { Text[] result = scheme.ansi().new Text(str(description, 0)).splitLines(); if (result.length == 0 || (result.length == 1 && result[0].plain.length() == 0)) { if (showDefault[0]) { result = new Text[]{scheme.ansi().new Text(" Default: " + arg.defaultValueString())}; showDefault[0] = false; // don't show the default value twice } else { result = new Text[]{ Ansi.EMPTY_TEXT }; } } return result; }