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

Fix progress and help options #234

Merged
Merged
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
28 changes: 27 additions & 1 deletion src/main/java/com/glencoesoftware/bioformats2raw/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public class Converter implements Callable<Integer> {
private volatile String logLevel;
private volatile boolean progressBars = false;
private volatile boolean printVersion = false;
private volatile boolean help = false;

private volatile int maxWorkers;
private volatile int maxCachedTiles;
Expand Down Expand Up @@ -401,7 +402,6 @@ public void setLogLevel(String level) {
@Option(
names = {"-p", "--progress"},
description = "Print progress bars during conversion",
help = true,
defaultValue = "false"
)
public void setProgressBars(boolean useProgressBars) {
Expand All @@ -424,6 +424,21 @@ public void setPrintVersionOnly(boolean versionOnly) {
printVersion = versionOnly;
}

/**
* Configure whether to print help and exit without converting.
*
* @param helpOnly whether or not to print help and exit
*/
@Option(
names = "--help",
description = "Print usage information and exit",
usageHelp = true,
defaultValue = "false"
)
public void setHelp(boolean helpOnly) {
help = helpOnly;
}

/**
* Set the maximum number of workers to use for converting tiles.
* Defaults to 4 or the number of detected CPUs, whichever is smaller.
Expand Down Expand Up @@ -918,6 +933,13 @@ public boolean getPrintVersionOnly() {
return printVersion;
}

/**
* @return true if only usage info is displayed
*/
public boolean getHelp() {
return help;
}

/**
* @return maximum number of worker threads
*/
Expand Down Expand Up @@ -1095,6 +1117,10 @@ public Integer call() throws Exception {
LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
root.setLevel(Level.toLevel(logLevel));

if (help) {
return -1;
}

if (printVersion) {
String version = Optional.ofNullable(
this.getClass().getPackage().getImplementationVersion()
Expand Down
Loading