Create the Parser
We now need to create a Parser. This will parse the command line arguments, using the rules specified by the Options and return an instance of CommandLine . This time we will use a GnuParser which is able to handle options that are more than one character long.
GnuParser is part of apache commons cli:
org.apache.commons.cli.GnuParser
CliBuilder has a parser field, so all you need to do is pass an instance as a named argument to the CliBuilder constructor like so:
def cli = new CliBuilder(usage: USAGE, parser: new GnuParser())
No comments:
Post a Comment