implicit.ly

Scala software, hot off the presses

scopt 1.1.2

  • Cross built against Scala 2.9.1, 2.9.0-1, and 2.8.1.

scopt is a little command line options parsing library.

Filed under  //   Scala 2.8.1   Scala 2.9.0-1   Scala 2.9.1   com.github.scopt   scopt  

scopt 1.1.0

  • Adds argOpt and arglistOpt method for optional arguments.

scopt is a little command line options parsing library.

Filed under  //   Scala 2.7.7   Scala 2.8.0   Scala 2.8.1   Scala 2.9.0-1   com.github.scopt   scopt  

scopt 1.0.0

hello, world

This is the initial release of scopt, a little command line parsing library.

You can customize an OptionParser by passing in functions to process each option or argument.

val parser = new OptionParser("scopt") {
  intOpt("f", "foo", "foo is an integer property", {v: Int => config.foo = v})
  opt("o", "output", "<file>", "output is a string property", {v: String => config.bar = v})
  booleanOpt("xyz", "xyz is a boolean property", {v: Boolean => config.xyz = v})
  keyValueOpt("l", "lib", "<libname>", "<filename>", "load library <libname>",
    {(key: String, value: String) => { config.libname = key; config.libfile = value } })
  arg("<singlefile>", "<singlefile> is an argument", {v: String => config.whatnot = v})
  // arglist("<file>...", "arglist allows variable number of arguments",
  //   {v: String => config.files = (v :: config.files).reverse })
}
if (parser.parse(args)) {
   // do stuff
}
else {
  // arguments are bad, usage message will have been displayed
}

It handles various kinds of options such as optional, required, and key-value. From the above, it also automatically generates the usage text as follows:

Usage: scopt [options] <filename>

  -f <value> | --foo <value>
        foo is an integer property
  -o <file> | --output <file>
        output is a string property
  --xyz <value>
        xyz is a boolean property
  -l:<libname>=<filename> | --lib:<libname>=<filename>
        load library <libname>
  <singlefile>
        <singlefile> is an argument

scopt is a little command line options parsing library.

Filed under  //   Scala 2.7.7   Scala 2.8.0   Scala 2.8.1   Scala 2.9.0-1   com.github.scopt   scopt