5.1 Interactive Mode
Interactive mode is a feature of the Grails command line which keeps the JVM running and allows for quicker execution of commands. To activate interactive mode type 'grails' at the command line and then use TAB completion to get a list of commands:
If you need to open a file whilst within interactive mode you can use the open
command which will TAB complete file paths:
Even better, the open
command understands the logical aliases 'test-report' and 'dep-report', which will open the most recent test and dependency reports respectively. In other words, to open the test report in a browser simply execute open test-report
. You can even open multiple files at once: open test-report test/unit/MyTests.groovy
will open the HTML test report in your browser and the MyTests.groovy
source file in your text editor.
TAB completion also works for class names after the create-*
commands:
If you need to run an external process whilst interactive mode is running you can do so by starting the command with a !:
Note that with ! (bang) commands, you get file path auto completion - ideal for external commands that operate on the file system such as 'ls', 'cat', 'git', etc.
To exit interactive mode enter the exit
command. Note that if the Grails application has been run with run-app
normally it will terminate when the interactive mode console exits because the JVM will be terminated. An exception to this would be if the application were running in forked mode which means the application is running in a different JVM. In that case the application will be left running after the interactive mode console terminates. If you want to exit interactive mode and stop an application that is running in forked mode, use the quit
command. The quit
command will stop the running application and then close interactive mode.