What's the best way to parse command-line parameters in Scala? I personally prefer something lightweight that does not require external jar.
Related:
What's the best way to parse command-line parameters in Scala? I personally prefer something lightweight that does not require external jar.
Related:
I like sliding over arguments for relatively simple configurations.
This is largely a shameless clone of my answer to the Java question of the same topic. It turns out that JewelCLI is Scala-friendly in that it doesn't require JavaBean style methods to get automatic argument naming.
JewelCLI is a Scala-friendly Java library for command-line parsing that yields clean code. It uses Proxied Interfaces Configured with Annotations to dynamically build a type-safe API for your command-line parameters.
An example parameter interface
Person.scala
:An example usage of the parameter interface
Hello.scala
:Save copies of the files above to a single directory and download the JewelCLI 0.6 JAR to that directory as well.
Compile and run the example in Bash on Linux/Mac OS X/etc.:
Compile and run the example in the Windows Command Prompt:
Running the example should yield the following output: