6.5 Creating Profile Commands - Reference Documentation
Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari
Version: 3.1.9
6.5 Creating Profile Commands
A profile can define new commands that apply only to that profile using YAML or Groovy scripts. Below is an example of the create-controller command defined in YAML:description:
- Creates a controller
- usage: 'create-controller [controller name]'
- completer: org.grails.cli.interactive.completers.DomainClassCompleter
- argument: "Controller Name"
description: "The name of the controller"
steps:
- command: render
template: templates/artifacts/Controller.groovy
destination: grails-app/controllers/artifact.package.path/artifact.nameController.groovy
- command: render
template: templates/testing/Controller.groovy
destination: src/test/groovy/artifact.package.path/artifact.nameControllerSpec.groovy
- command: mkdir
location: grails-app/views/artifact.propertyNamerender- To render a template to a given destination (as seen in the previous example)mkdir- To make a directory specified by thelocationparameterexecute- To execute a command specified by theclassparameter. Must be a class that implements the Command interface.gradle- To execute one or many Gradle tasks specified by thetasksparameter.
description: Creates a WAR file for deployment to a container (like Tomcat)
minArguments: 0
usage: |
war
steps:
- command: gradle
tasks:
- wardescription( "Creates a Grails script" ) { usage "grails create-script [SCRIPT NAME]" argument name:'Script Name', description:"The name of the script to create" flag name:'force', description:"Whether to overwrite existing files" }def scriptName = args[0] def model = model(scriptName) def overwrite = flag('force') ? true : falserender template: template('artifacts/Script.groovy'), destination: file("src/main/scripts/${model.lowerCaseName}.groovy"), model: model, overwrite: overwrite
