(Quick Reference)

4.1 交互模式 - Reference Documentation

Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith

Version: null

4.1 交互模式

交互模式是保持在JVM上运行,并允许更快地执行命令的Grails命令的功能。要激活交互模式可以再命令行中键入'Grails',然后使用Tab键补全获取命令列表:

如果你需要在交互模式中打开一个文件,你可以使用open命令和用TAB键完成文件路径:

更妙的是,open命令会识别'test-report' 和 'dep-report'这个两个逻辑别名,这将打开近期的测试和依赖报告。换句话说,在浏览器中打开测试报告仅需简单地执行open test-report命令。您甚至可以一次打开多个文件:open test-report test/unit/MyTests.groovy 将在您的浏览器打开的HTML测试报告和在你的文本编辑器中打开MyTests.groovy源文件。

create-*命令后面按TAB键补全完成类名同样是起作用的:

在交互模式中如果你需要运行一个外部进程,你可以用命令a !:

请注意你可以用! (bang)命令让文件路径自动完成 - 非常适合像'ls', 'cat', 'git'等操作文件系统的外部命令。

Interactive mode is the 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 event 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.