Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Simplify usage and error catching logic
Browse files Browse the repository at this point in the history
  • Loading branch information
fieldju committed Dec 12, 2016
1 parent 321163d commit e645c01
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

group=com.nike
artifactId=cerberus-lifecycle-cli
version=0.8.0
version=0.9.0
22 changes: 7 additions & 15 deletions src/main/java/com/nike/cerberus/cli/CerberusRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,16 @@ public void run(String[] args) {
operation.run(command);
}
}
} catch (IllegalArgumentException e) {
System.err.println(Chalk.on("ERROR: " + e.getMessage()).red().bold().toString());
cerberusCommand = new CerberusCommand();
new JCommander(cerberusCommand).usage();
} catch (ParameterException pe) {
} catch (Throwable e) {
if (! cerberusCommand.isHelp()) {
System.err.println(Chalk.on("ERROR: " + pe.getMessage()).red().bold().toString());
System.err.println(Chalk.on("ERROR: " + e.getMessage()).red().bold().toString());
}
if (pe instanceof MissingCommandException) {
printCommands();

String commandName = commander.getParsedCommand();
if (StringUtils.isNotBlank(commandName)) {
commander.usage(commandName);
} else {
String commandName = commander.getParsedCommand();
if (StringUtils.isNotBlank(commandName)) {
commander.usage(commandName);
} else {
// we shouldn't be able to get here, but we will leave it here just in case
commander.usage();
}
printCustomUsage();
}
}
}
Expand Down

0 comments on commit e645c01

Please sign in to comment.