Skip to content

Commit

Permalink
Merge pull request #34459 from danielsoro/QUARKUS-34103
Browse files Browse the repository at this point in the history
Making --verbose a global flag
  • Loading branch information
ebullient authored Jul 5, 2023
2 parents 8eff475 + bcf98f1 commit 0f830fd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
4 changes: 4 additions & 0 deletions devtools/cli/src/main/java/io/quarkus/cli/QuarkusCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public class QuarkusCli implements QuarkusApplication, Callable<Integer> {
@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -157,7 +170,7 @@ public int handleCommandException(Exception ex, String message) {
public String toString() {
return "OutputOptions [testMode=" + cliTestMode
+ ", showErrors=" + showErrors
+ ", verbose=" + verbose + "]";
+ ", verbose=" + getVerbose() + "]";
}

}

0 comments on commit 0f830fd

Please sign in to comment.