diff --git a/src/main/java/com/glencoesoftware/bioformats2raw/Converter.java b/src/main/java/com/glencoesoftware/bioformats2raw/Converter.java index 03240ad..1e72ccc 100644 --- a/src/main/java/com/glencoesoftware/bioformats2raw/Converter.java +++ b/src/main/java/com/glencoesoftware/bioformats2raw/Converter.java @@ -138,6 +138,7 @@ public class Converter implements Callable { 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; @@ -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) { @@ -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. @@ -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 */ @@ -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()