added a comment - - edited
Issue is universal. e.g. MacOSX, 2.0.0-beta-3
Fix: Pull Request - https://github.com/groovy/groovy-core/pull/28
it's not a commons cli problem. The problems is inside the logic how GroovyMain parses it's args and determines whether it will need the params to itself or pass them to your scriptFile.
Since '-p' and '-a' are Options in GroovyMain and you specified '-param', GroovyMain will extract '-p', and '-a' and give you the rest, which it did not recognize => 'ram'
Therefore the --encoding param is just one example on how this fails.
You can take any params abbreviation, which is used by GroovyMain.
The current logic determines the name of the scriptfile you want to run, too late, which explains, why
groovy --encoding=UTF-8 main.groovy -script -param
groovy main.groovy -script -param
does not fail.
So, I think we should force the convention that you first enter all params for the GrooyMain part, then an optional scriptFile and optional scriptArgs.
groovy [options] [scriptName scriptArgs]