Skip to content

Commit

Permalink
Merge branch '2.5.x' into 3.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed Jun 18, 2015
2 parents 368202d + b0ac122 commit 556505b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public InputStream getInput() {
private void assertAllowInput() {
assertAllowInput(null);
}

private void assertAllowInput(String prompt) {
if (reader == null) {
String msg = "User input is not enabled, cannot obtain input stream";
Expand Down Expand Up @@ -1009,7 +1009,19 @@ public void restoreOriginalSystemOutAndErr() {
System.setErr(originalSystemErr);
}

public void cleanlyExit(int status) {
flush();
System.exit(status);
}

/**
* Makes sure that the console has been reset to the default state and that
* the out stream has been flushed.
*/
public void flush() {
if (isAnsiEnabled()) {
out.print(ansi().reset().toString());
}
out.flush();
}

Expand Down
16 changes: 10 additions & 6 deletions grails-shell/src/main/groovy/org/grails/cli/GrailsCli.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,23 @@ class GrailsCli {
public static void main(String[] args) {
GrailsCli cli=new GrailsCli()
try {
System.exit(cli.execute(args))
exit(cli.execute(args))
}
catch(BuildCancelledException e) {
GrailsConsole.instance.addStatus("Build stopped.")
System.exit(0)
exit(0)
}
catch (Throwable e) {
e = ExceptionUtils.getRootCause(e)
GrailsConsole.instance.error("Error occurred running Grails CLI: $e.message", e)
System.exit(1)
exit(1)
}
}

static void exit(int code) {
GrailsConsole.instance.cleanlyExit(code)
}

static boolean isInteractiveModeActive() {
return interactiveModeActive
}
Expand Down Expand Up @@ -142,13 +146,13 @@ class GrailsCli {
console.addStatus("Grails Version: ${GrailsCli.getPackage().implementationVersion}")
console.addStatus("Groovy Version: ${GroovySystem.version}")
console.addStatus("JVM Version: ${System.getProperty('java.version')}")
System.exit(0)
exit(0)
}

if(mainCommandLine.hasOption(CommandLine.HELP_ARGUMENT) || mainCommandLine.hasOption('h')) {
def cmd = CommandRegistry.getCommand("help", profileRepository)
cmd.handle(createExecutionContext(mainCommandLine))
System.exit(0)
exit(0)
}

if(mainCommandLine.environmentSet) {
Expand Down Expand Up @@ -373,7 +377,7 @@ class GrailsCli {
} catch (Throwable e) {
e = ExceptionUtils.getRootCause(e)
GrailsConsole.instance.error("Error initializing classpath: $e.message", e)
System.exit(1)
exit(1)
}
}

Expand Down

0 comments on commit 556505b

Please sign in to comment.