Skip to content

Commit

Permalink
Merge pull request #124 from prezi/dont_exit_from_main
Browse files Browse the repository at this point in the history
Don't exit from main() when it's not necessary
  • Loading branch information
lptr committed Dec 5, 2014
2 parents ac86156 + 9c122eb commit 4e23ae5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pride/src/main/java/com/prezi/gradle/pride/cli/PrideCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ public class PrideCli {

private static final org.slf4j.Logger logger = LoggerFactory.getLogger(PrideCli.class);

@SuppressWarnings("unchecked")
public static void main(String... args) {
System.exit(execute(args));
}

@SuppressWarnings("unchecked")
public static int execute(String... args) {
Cli.CliBuilder<Callable<?>> builder = Cli.builder("pride");
builder
.withDescription("manages a pride of modules")
Expand Down Expand Up @@ -57,7 +61,7 @@ public static void main(String... args) {
}

logger.error("{}", e.getMessage());
System.exit(-1);
return -1;
}

boolean verbose = false;
Expand All @@ -67,7 +71,7 @@ public static void main(String... args) {
if (command.isHelp()) {
CommandMetadata commandMetadata = findCommandMetadata(parser.getMetadata(), command.getClass());
Help.help(commandMetadata);
System.exit(0);
return 0;
}
Logger rootLogger = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
if (command.isVerbose()) {
Expand Down Expand Up @@ -95,7 +99,8 @@ public static void main(String... args) {
logger.error("Exception:", e);
exitValue = -1;
}
System.exit(exitValue);

return exitValue;
}

private static CommandMetadata findCommandMetadata(GlobalMetadata global, Class<? extends PrideCommand> type) {
Expand Down

0 comments on commit 4e23ae5

Please sign in to comment.