Skip to content

Commit 728a30f

Browse files
committed
TIKA-4455: replace deprecated; add help option if not in xml
1 parent 3c63d5f commit 728a30f

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

tika-batch/src/main/java/org/apache/tika/batch/fs/FSBatchProcessCLI.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
import org.apache.commons.cli.CommandLine;
3030
import org.apache.commons.cli.CommandLineParser;
3131
import org.apache.commons.cli.DefaultParser;
32-
import org.apache.commons.cli.HelpFormatter;
3332
import org.apache.commons.cli.Option;
3433
import org.apache.commons.cli.Options;
34+
import org.apache.commons.cli.help.HelpFormatter;
3535
import org.apache.commons.io.IOUtils;
3636
import org.slf4j.Logger;
3737
import org.slf4j.LoggerFactory;
@@ -55,6 +55,9 @@ public FSBatchProcessCLI(String[] args) throws IOException {
5555
configIs = getConfigInputStream(args, true);
5656
CommandLineParserBuilder builder = new CommandLineParserBuilder();
5757
options = builder.build(configIs);
58+
if (!options.hasOption("help")) {
59+
options.addOption("?", "help", false, "this help message");
60+
}
5861
} finally {
5962
IOUtils.closeQuietly(configIs);
6063
}
@@ -71,9 +74,9 @@ public static void main(String[] args) throws Exception {
7174
}
7275
}
7376

74-
public void usage() {
75-
HelpFormatter helpFormatter = new HelpFormatter();
76-
helpFormatter.printHelp("tika filesystem batch", options);
77+
public void usage() throws IOException {
78+
HelpFormatter helpFormatter = HelpFormatter.builder().get();
79+
helpFormatter.printHelp("tika filesystem batch", null, options, null, true);
7780
}
7881

7982
private TikaInputStream getConfigInputStream(String[] args, boolean logDefault) throws IOException {

0 commit comments

Comments
 (0)