final String stg = buff.toString(); try { reader.printString(stg);
final String stg = buff.toString(); try { reader.printString(stg);
private String boldIfPossible(String message) { ANSIBuffer query = new ANSIBuffer(); query.setAnsiEnabled(useAnsiColor); query.bold(message); return query.toString(); }
private <T> Pair<String, Map<String, T>> formatAnsiChoiceMessage(String message, Iterable<T> choices, Function<T, String> choiceDisplay) throws PrompterException { ANSIBuffer query = new ANSIBuffer(); query.bold(message + ":\n"); List<String> answers = new ArrayList<>(); Map<String, T> answerValueMap = new HashMap<>(); int counter = 1; for (T choice : choices) { String answer = String.valueOf(counter); query.bold(answer); if (counter < 10) { query.append(": "); } else { query.append(": "); } query.append(choiceDisplay.apply(choice)).append("\n"); answers.add(answer); answerValueMap.put(answer, choice); counter++; } return Pair.of(query.toString(), answerValueMap); }
private void promptAnsi(String latestVersion) throws PrompterException { ANSIBuffer ansiBuffer = new ANSIBuffer(); ansiBuffer.append(ANSIBuffer.ANSICodes.attrib(PrettyPrompter.FG_YELLOW)) .append("************************************************************") .append("\nVersion " + latestVersion + " of the Atlassian Plugin SDK is now available.\n") .append("Run the atlas-update command to update.\n") .append("************************************************************") .append(ANSIBuffer.ANSICodes.attrib(PrettyPrompter.OFF)); getLogger().warn(ansiBuffer.toString()); // prompter.prompt(ansiBuffer.toString()); }
return formatted.toString();
return new MessageAndAnswers(formatted.toString(),answers,defaultAnswer);
return formatted.toString();
protected String requiredMessage(String message) { String formattedMessage = message; if (useAnsiColor) { ANSIBuffer ansiBuffer = new ANSIBuffer(); ansiBuffer.append(ANSIBuffer.ANSICodes .attrib(PrettyPrompter.BOLD)) .append(ANSIBuffer.ANSICodes .attrib(PrettyPrompter.FG_RED)) .append(message) .append(ANSIBuffer.ANSICodes .attrib(PrettyPrompter.OFF)); formattedMessage = ansiBuffer.toString(); } return formattedMessage; }
public String requiredMessage(String message) { String formattedMessage = message; if (useAnsiColor) { ANSIBuffer ansiBuffer = new ANSIBuffer(); ansiBuffer.append(ANSIBuffer.ANSICodes .attrib(PrettyPrompter.BOLD)) .append(ANSIBuffer.ANSICodes .attrib(PrettyPrompter.FG_RED)) .append(message) .append(ANSIBuffer.ANSICodes .attrib(PrettyPrompter.OFF)); formattedMessage = ansiBuffer.toString(); } return formattedMessage; }
private void promptForEmailAnsi() throws PrompterException, IOException { ANSIBuffer ansiBuffer = new ANSIBuffer(); ansiBuffer.append(ANSIBuffer.ANSICodes.attrib(PrettyPrompter.FG_YELLOW)) .append("Would you like to subscribe to the Atlassian developer mailing list?") .append(ANSIBuffer.ANSICodes.attrib(PrettyPrompter.OFF)); boolean signUp = promptForBoolean(ansiBuffer.toString(),"Y"); if(signUp) { ANSIBuffer ansiEmailBuffer = new ANSIBuffer(); ansiEmailBuffer.append(ANSIBuffer.ANSICodes.attrib(PrettyPrompter.FG_GREEN)) .append("Please enter your email address (leave blank to cancel):") .append(ANSIBuffer.ANSICodes.attrib(PrettyPrompter.OFF)); String email = prompter.prompt(ansiEmailBuffer.toString()); if(StringUtils.isNotBlank(email) && EmailValidator.getInstance().isValid(email)) { doSubscribe(email); } } }
final String stg = buff.toString(); try { reader.printString(stg);
@Override public void showError(String message) throws PrompterException { String formattedMessage = message; if (useAnsiColor) { ANSIBuffer ansiBuffer = new ANSIBuffer(); ansiBuffer.append(ANSIBuffer.ANSICodes .attrib(PrettyPrompter.BOLD)) .append(ANSIBuffer.ANSICodes .attrib(PrettyPrompter.FG_RED)) .append(message) .append(ANSIBuffer.ANSICodes .attrib(PrettyPrompter.OFF)); formattedMessage = ansiBuffer.toString(); } showMessage(formattedMessage); }
@Override public void showInfo(String message) throws PrompterException { String formattedMessage = message; if (useAnsiColor) { ANSIBuffer ansiBuffer = new ANSIBuffer(); ansiBuffer.append(ANSIBuffer.ANSICodes .attrib(PrettyPrompter.BOLD)) .append(ANSIBuffer.ANSICodes .attrib(PrettyPrompter.FG_GREEN)) .append(message) .append(ANSIBuffer.ANSICodes .attrib(PrettyPrompter.OFF)); formattedMessage = ansiBuffer.toString(); } showMessage(formattedMessage); }
@Override public void showWarning(String message) throws PrompterException { String formattedMessage = message; if (useAnsiColor) { ANSIBuffer ansiBuffer = new ANSIBuffer(); ansiBuffer.append(ANSIBuffer.ANSICodes .attrib(PrettyPrompter.BOLD)) .append(ANSIBuffer.ANSICodes .attrib(PrettyPrompter.FG_YELLOW)) .append(message) .append(ANSIBuffer.ANSICodes .attrib(PrettyPrompter.OFF)); formattedMessage = ansiBuffer.toString(); } showMessage(formattedMessage); }
.append(ANSIBuffer.ANSICodes .attrib(OFF)); invalid = ansiBuffer.toString();
private boolean promptForUpdateAnsi(DefaultArtifactVersion ampsVersionInPom, DefaultArtifactVersion runningVersion) throws PrompterException { ANSIBuffer ansiBuffer = new ANSIBuffer(); ansiBuffer.append(ANSIBuffer.ANSICodes.attrib(PrettyPrompter.FG_YELLOW)) .append("You are running SDK version ") .append(runningVersion.toString()) .append(" but your pom is using version ") .append(ampsVersionInPom.toString()) .append("\n") .append(ANSIBuffer.ANSICodes.attrib(PrettyPrompter.OFF)) .append(ANSIBuffer.ANSICodes.attrib(PrettyPrompter.BOLD)) .append("Would you like to have your pom updated?") .append(ANSIBuffer.ANSICodes.attrib(PrettyPrompter.OFF)); return promptForBoolean(ansiBuffer.toString(),"Y"); }
decoratedInput = ansiBuffer.toString();