Daniel Ribeiro
Daniel Ribeiro

Reputation: 182

How to declare and accept parameters in a grails 3.0 create-script

Using the create-script Grails creates a Gant script. I've seen that through argsMap I have access to the input parameters. e.g.

grails run my-script --parameter1=value1 --parameter2=value2

I can access parameters like this:

argsMap.parameter1 == value1
argsMap.parameter2 == value2

How can I make a script that only accepts one domain class as parameter without the need to specify --parameterName. eg

grails my-script foo.MyDomainClass

Upvotes: 0

Views: 90

Answers (1)

saw303
saw303

Reputation: 9072

According to the Javadoc of GroovyScriptCommand (see that link) you can use the args list instead of the argsMap.

Simply use args[0] in your script instead of a named parameter.

Upvotes: 1

Related Questions