From 5b8cda5c0feeffa119a53a90b44bda4cc43bcee2 Mon Sep 17 00:00:00 2001 From: Jean Francois Denise Date: Thu, 28 Mar 2024 14:21:45 +0100 Subject: [PATCH] Better message for suggest --- .../org/wildfly/glow/cli/commands/ScanCommand.java | 1 + core/src/main/java/org/wildfly/glow/Arguments.java | 13 ++++++++++++- .../java/org/wildfly/glow/BaseArgumentsBuilder.java | 4 +++- .../main/java/org/wildfly/glow/ScanArguments.java | 5 +++++ .../java/org/wildfly/glow/ScanResultsPrinter.java | 2 +- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/cli/src/main/java/org/wildfly/glow/cli/commands/ScanCommand.java b/cli/src/main/java/org/wildfly/glow/cli/commands/ScanCommand.java index 73763d73..ac741e82 100644 --- a/cli/src/main/java/org/wildfly/glow/cli/commands/ScanCommand.java +++ b/cli/src/main/java/org/wildfly/glow/cli/commands/ScanCommand.java @@ -261,6 +261,7 @@ public Integer call() throws Exception { throw new Exception("Can only set a docker image name when provisioning a docker image. Remove the " + Constants.DOCKER_IMAGE_NAME_OPTION + " option"); } } + builder.setIsCli(true); ScanResults scanResults = GlowSession.scan(MavenResolver.newMavenResolver(), builder.build(), GlowMessageWriter.DEFAULT); scanResults.outputInformation(); if (provision.isEmpty()) { diff --git a/core/src/main/java/org/wildfly/glow/Arguments.java b/core/src/main/java/org/wildfly/glow/Arguments.java index c1b41742..c348307a 100644 --- a/core/src/main/java/org/wildfly/glow/Arguments.java +++ b/core/src/main/java/org/wildfly/glow/Arguments.java @@ -35,6 +35,7 @@ public class Arguments implements GoOfflineArguments, ScanArguments { private final Set excludeArchivesFromScan; private final Stability configStability; private final Stability packageStability; + private final boolean isCli; protected Arguments( String executionContext, @@ -51,7 +52,8 @@ protected Arguments( boolean techPreview, Set excludeArchivesFromScan, Stability configStability, - Stability packageStability) { + Stability packageStability, + boolean isCli) { this.executionProfiles = executionProfiles; this.userEnabledAddOns = userEnabledAddOns; this.binaries = binaries; @@ -76,6 +78,7 @@ protected Arguments( } else { this.manualLayers = new HashSet<>(Arrays.asList(manualLayers.split(","))); } + this.isCli = isCli; } /** @@ -191,6 +194,14 @@ public Stability getPackageStability() { return packageStability; } + /** + * @return the isCli + */ + @Override + public boolean isCli() { + return isCli; + } + static GoOfflineArguments.Builder goOfflineBuilder() { return new GoOfflineArguments.Builder(); } diff --git a/core/src/main/java/org/wildfly/glow/BaseArgumentsBuilder.java b/core/src/main/java/org/wildfly/glow/BaseArgumentsBuilder.java index 53f7a8fb..3bf80155 100644 --- a/core/src/main/java/org/wildfly/glow/BaseArgumentsBuilder.java +++ b/core/src/main/java/org/wildfly/glow/BaseArgumentsBuilder.java @@ -42,6 +42,7 @@ public class BaseArgumentsBuilder { protected Set excludeJarsFromScan = Collections.emptySet(); protected Stability packageStability; protected Stability configStability; + protected boolean isCli; protected BaseArgumentsBuilder() { @@ -67,6 +68,7 @@ public Arguments build() { techPreview, excludeJarsFromScan, configStability, - packageStability); + packageStability, + isCli); } } diff --git a/core/src/main/java/org/wildfly/glow/ScanArguments.java b/core/src/main/java/org/wildfly/glow/ScanArguments.java index 83fcce44..ff6eac3d 100644 --- a/core/src/main/java/org/wildfly/glow/ScanArguments.java +++ b/core/src/main/java/org/wildfly/glow/ScanArguments.java @@ -76,6 +76,7 @@ public interface ScanArguments { Stability getConfigStability(); Stability getPackageStability(); + boolean isCli(); default Builder createScanArgumentsBuilder() { return new Builder(); @@ -163,5 +164,9 @@ public Builder setConfigStability(Stability stability) { this.configStability = stability; return this; } + public Builder setIsCli(boolean isCli) { + this.isCli = isCli; + return this; + } } } diff --git a/core/src/main/java/org/wildfly/glow/ScanResultsPrinter.java b/core/src/main/java/org/wildfly/glow/ScanResultsPrinter.java index ae1ed8a5..a47c067e 100644 --- a/core/src/main/java/org/wildfly/glow/ScanResultsPrinter.java +++ b/core/src/main/java/org/wildfly/glow/ScanResultsPrinter.java @@ -277,7 +277,7 @@ private void detailed(ScanArguments arguments, ScanResults scanResults) throws E } } else { if (!scanResults.getSuggestions().getPossibleAddOns().isEmpty() || !scanResults.getSuggestions().getPossibleAddOns().isEmpty() || !suggestedConfigs.isEmpty() || !suggestedBuildTimeConfigs.isEmpty()) { - writer.info("Some suggestions have been found. You could enable suggestions with the --suggest option (if using the WildFly Glow CLI) or true (if using the WildFly Maven Plugin)."); + writer.info("Some suggestions have been found. You could enable suggestions with the " + (arguments.isCli() ? "--suggest" : "true") + " option."); } } }