Grails run - script with argument

I want to create a grails script that adds an administrator account to my application. Sort of:

grails run-script utils/adminAdd.groovy username password 

Unfortunately, it seems that the run-script does not support passing arguments to scripts (allowing you to run multiple scripts instead instead). Does anyone know a workaround?

+4
source share
2 answers

This should be supported, so you should create a problem at http://jira.grails.org/browse/GRAILS

In the meantime, I think in order to maintain backward compatibility, you probably need a way to differentiate script names from args, for example. prefix:

 grails run-script utils/adminAdd.groovy -Jusername -Jpassword -Jfoo=bar 

Then run-script can split the args list into un-prefixed script names and send de-prefix arguments to each script as it runs.

As soon as you receive it, send a transfer request locally or attach the updated script to JIRA and it will be fixed much faster.

+3
source

See my answer. How do I run the Groovy class from the command line in Grails?

In short, you need includeTargets << grailsScript("_GrailsArgParsing") in the script; See the documentation for more options.

0
source

All Articles