How to capture arguments passed to a Groovy script?
Sorry about asking the question. I just figured it out:
println args[0]
println args[1]
println args[2]
If you want more advanced parsing than just getting the arguments you can use the Groovy CliBuilder to help you. It helps you with commandline flags, optional arguments and printing the usage instruction.
Checkout CliBuilder's Javadoc or MrHakis post about it.
The simplest is just to use this.args
as an array e.g.:
test.groovy
println this.args[0]
Call:
C:>groovy test this
Output:
this