Skip to content

Commit

Permalink
Merge pull request #234 from melissalinkert/fix-progress-option
Browse files Browse the repository at this point in the history
Fix progress and help options
  • Loading branch information
chris-allan authored Jan 18, 2024
2 parents 26aeae2 + 699ee76 commit 7ddc0ee
Showing 1 changed file with 27 additions and 1 deletion.
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 @@ -919,6 +934,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 @@ -1096,6 +1118,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

0 comments on commit 7ddc0ee

Please sign in to comment.