Skip to content

Commit

Permalink
Migrate to use ConsoleTextTerminal in web app config mojo
Browse files Browse the repository at this point in the history
  • Loading branch information
Flanker32 committed Nov 19, 2021
1 parent fd96519 commit a677a87
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.beryx.textio.TextIO;
import org.beryx.textio.TextIoFactory;
import org.beryx.textio.console.ConsoleTextTerminal;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.dom4j.DocumentException;

Expand Down Expand Up @@ -490,8 +489,7 @@ private WebAppConfiguration chooseExistingWebappForConfiguration()
final List<WebAppOption> javaOrDockerWebapps = webAppOptionList.stream().filter(app -> app.isJavaWebApp() || app.isDockerWebapp())
.filter(app -> checkWebAppVisible(isContainer, isDockerOnly, app.isJavaSE(), app.isDockerWebapp())).sorted()
.collect(Collectors.toList());
final TextIO textIO = TextIoFactory.getTextIO();
final WebAppOption selectedApp = selectAzureWebApp(textIO, javaOrDockerWebapps,
final WebAppOption selectedApp = selectAzureWebApp(javaOrDockerWebapps,
getWebAppTypeByPackaging(this.project.getPackaging()), az.getDefaultSubscription());
if (selectedApp == null || selectedApp.isCreateNew()) {
return null;
Expand All @@ -511,7 +509,7 @@ private WebAppConfiguration chooseExistingWebappForConfiguration()
}
}

private static WebAppOption selectAzureWebApp(TextIO textIO, List<WebAppOption> javaOrDockerWebapps, String webAppType, Subscription targetSubscription) {
private static WebAppOption selectAzureWebApp(List<WebAppOption> javaOrDockerWebapps, String webAppType, Subscription targetSubscription) {
final List<WebAppOption> options = new ArrayList<>();
options.add(WebAppOption.CREATE_NEW);
// check empty: second time
Expand All @@ -520,7 +518,7 @@ private static WebAppOption selectAzureWebApp(TextIO textIO, List<WebAppOption>
return null;
}
options.addAll(javaOrDockerWebapps);
return new CustomTextIoStringListReader<WebAppOption>(textIO::getTextTerminal, null)
return new CustomTextIoStringListReader<WebAppOption>(ConsoleTextTerminal::new, null)
.withCustomPrompt(String.format("Please choose a %s Web App%s: ", webAppType, highlightDefaultValue(WebAppOption.CREATE_NEW.toString())))
.withNumberedPossibleValues(options).withDefaultValue(WebAppOption.CREATE_NEW)
.read(String.format("%s Web Apps in subscription %s:", webAppType, TextUtils.blue(targetSubscription.getName())));
Expand Down

0 comments on commit a677a87

Please sign in to comment.