diff --git a/devtools/cli/src/main/java/io/quarkus/cli/QuarkusCli.java b/devtools/cli/src/main/java/io/quarkus/cli/QuarkusCli.java index 3db8a4d8c3af2..f38f745fa3081 100644 --- a/devtools/cli/src/main/java/io/quarkus/cli/QuarkusCli.java +++ b/devtools/cli/src/main/java/io/quarkus/cli/QuarkusCli.java @@ -79,6 +79,10 @@ public class QuarkusCli implements QuarkusApplication, Callable { @CommandLine.ArgGroup(exclusive = false, validate = false) protected PropertiesOptions propertiesOptions = new PropertiesOptions(); + public OutputOptionMixin getOutput() { + return output; + } + @Override public int run(String... args) throws Exception { CommandLine cmd = factory == null ? new CommandLine(this) : new CommandLine(this, factory); diff --git a/devtools/cli/src/main/java/io/quarkus/cli/common/OutputOptionMixin.java b/devtools/cli/src/main/java/io/quarkus/cli/common/OutputOptionMixin.java index e4cd6f2963f56..50bb36be6c48f 100644 --- a/devtools/cli/src/main/java/io/quarkus/cli/common/OutputOptionMixin.java +++ b/devtools/cli/src/main/java/io/quarkus/cli/common/OutputOptionMixin.java @@ -8,6 +8,7 @@ import java.nio.file.Paths; import java.util.List; +import io.quarkus.cli.QuarkusCli; import io.quarkus.devtools.messagewriter.MessageWriter; import picocli.CommandLine; import picocli.CommandLine.Help.ColorScheme; @@ -17,12 +18,11 @@ public class OutputOptionMixin implements MessageWriter { static final boolean picocliDebugEnabled = "DEBUG".equalsIgnoreCase(System.getProperty("picocli.trace")); + boolean verbose = false; + @CommandLine.Option(names = { "-e", "--errors" }, description = "Print more context on errors and exceptions.") boolean showErrors; - @CommandLine.Option(names = { "--verbose" }, description = "Verbose mode.") - boolean verbose; - @CommandLine.Option(names = { "--cli-test" }, hidden = true, description = "Manually set output streams for unit test purposes.") boolean cliTestMode; @@ -70,8 +70,21 @@ public boolean isShowErrors() { return showErrors || picocliDebugEnabled; } + private static OutputOptionMixin getOutput(CommandSpec commandSpec) { + return ((QuarkusCli) commandSpec.root().userObject()).getOutput(); + } + + @CommandLine.Option(names = { "--verbose" }, description = "Verbose mode.") + public void setVerbose(boolean verbose) { + getOutput(mixee).verbose = verbose; + } + + public boolean getVerbose() { + return getOutput(mixee).verbose; + } + public boolean isVerbose() { - return verbose || picocliDebugEnabled; + return getVerbose() || picocliDebugEnabled; } public boolean isCliTest() { @@ -157,7 +170,7 @@ public int handleCommandException(Exception ex, String message) { public String toString() { return "OutputOptions [testMode=" + cliTestMode + ", showErrors=" + showErrors - + ", verbose=" + verbose + "]"; + + ", verbose=" + getVerbose() + "]"; } }