我需要在Grails 3中创建自定义命令,然后我可以从命令行执行,因为我们可以生成默认命令,例如run-app。我不确定是否要创建脚本或其他任何东西来实现这一点。
答案 0 :(得分:1)
说明似乎有效
[0] % grails create-app script-test
| Application created at /Users/kirk/tmp/script-test
[0] % cd script-test
[0] % grails create-script my-script
BUILD SUCCESSFUL
| Rendered template Script.groovy to destination src/main/scripts/my-script.groovy
[0] % cat src/main/scripts/my-script.groovy
description "Example description", "grails example-usage"
println "Example Script"%
[0] % grails my-script
Example Script
[0] % grails
| Enter a command name to run. Use TAB for completion:
grails> my-script
Example Script
标签完成也有效。
但是,如果在运行交互式shell的情况下创建脚本,则在重新启动shell之前,该shell不会看到该脚本。
[0] % grails
| Enter a command name to run. Use TAB for completion:
grails> create-script wibble
| Rendered template Script.groovy to destination src/main/scripts/wibble.groovy
grails> wibble
| Error Command not found wibble
Did you mean: assemble or clean or gradle?
grails> % quit
[0] % grails wibble
Example Script
grails> wibble
Example Script
grails>
答案 1 :(得分:0)
救援文件! Here是如何做你要求的。