Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making --verbose a global flag #34459

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() + "]";
}

}