Skip to content

Commit

Permalink
MID-8842 ninja - upgrade command, input dialog improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Aug 31, 2023
1 parent f26d3c1 commit 5559fe9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public VerifyResult execute() throws Exception {
log.info("XML dump with delta for each item saved to '{}'", options.getOutput().getPath() + VerificationReporter.DELTA_FILE_NAME_SUFFIX);
}

// todo this should not show when action is a part of complex action and next step is prepared automatically
// FIXME: ADD links (do not display in batch mode)
// FIXME: Could We could try to infer script name?
if (context.isUserMode()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public String getOperationName() {
@Override
public ActionResult<Void> execute() throws Exception {
File tempDirectory = createTmpDirectory(options.getTempDirectory());
// FIXME: Should we log pre-upgrade checks
// todo: Should we log pre-upgrade checks

// pre-upgrade checks
if (!options.isSkipPreCheck()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,13 @@ public void log(LogLevel level, String message, Object... args) {

stream.println(ConsoleFormat.formatLogMessage(level, formatted));
}

/**
* Prints raw message without any processing, not even new line character at the end.
*
* @param message
*/
public void logRaw(String message) {
stream.print(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,11 @@ public static String rewriteConsoleLine(String newLine) {
.cursorUpLine().eraseLine(Ansi.Erase.ALL)
.a(newLine).toString();
}

public static String formatInputPrompt() {
return Ansi.ansi()
.reset()
.a("[").fgBright(Ansi.Color.MAGENTA).a("INPUT").reset().a("] > ")
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ private static boolean containsFileNames(String[] names, String filenameRegex) {
return Arrays.stream(names).anyMatch(s -> s.matches(filenameRegex));
}

public static String readInput(Log log, Function<String, Boolean> inputValidation) throws IOException {
public static String readInput(Log log, Function<String, Boolean> inputValidation) {
log.logRaw(ConsoleFormat.formatInputPrompt());
boolean first = true;

String line = null;
Expand All @@ -288,6 +289,7 @@ public static String readInput(Log log, Function<String, Boolean> inputValidatio
while (!accepted) {
if (!first) {
log.error("Invalid input, please try again");
log.logRaw(ConsoleFormat.formatInputPrompt());
}
first = false;

Expand Down

0 comments on commit 5559fe9

Please sign in to comment.