cli now handles unrecognized commands without crashing

This commit is contained in:
de Beaubien, Bill 2015-12-03 15:19:26 -05:00
parent 2f8278ff78
commit 54a63ba8d7
1 changed files with 8 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.text.WordUtils;
import org.fusesource.jansi.Ansi;
import org.fusesource.jansi.Ansi.Color;
import org.fusesource.jansi.AnsiConsole;
import org.slf4j.LoggerFactory;
@ -159,6 +160,13 @@ public class App {
}
}
if (command == null) {
System.out.println("Unrecognized command: " + ansi().bold().fg(Color.RED) + theArgs[0] + ansi().boldOff().fg(Ansi.Color.WHITE));
System.out.println();
logUsage();
return;
}
Options options = command.getOptions();
DefaultParser parser = new DefaultParser();
CommandLine parsedOptions;