Skip to content

Commit

Permalink
Add explicit "--help" option
Browse files Browse the repository at this point in the history
  • Loading branch information
melissalinkert committed Jan 15, 2024
1 parent f3c256a commit 699ee76
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions 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 @@ -423,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 @@ -917,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 @@ -1094,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

0 comments on commit 699ee76

Please sign in to comment.