I am using Apache commons cli (1.2) for command line parsing.
I have the following in my code:
import org.apache.commons.cli.OptionBuilder
OptionBuilder.withLongOpt("db-host").hasArg.
withDescription("Name of the database host").create('h')
I get the error hasArg is not a member of org.apache.commons.cli.OptionBuilder
. It makes no difference if I change .hasArg
to .hasArg()
.
Why?
BTW, Java parses this fine.
Because there is no instance method
hasArg
inOptionBuilder
, only a static method. SincehasArg
is a static method, you obviously need to call it on the class, not on an instance of the class.I don't understand what this has to do with parsing. Scala parses this just fine, too. Plus, what some completely different programming does or doesn't do with this code is utterly irrelevant, since this is Scala code, not some other language.
You need to do something like this: