twitter/scalding — pull request #336 by tchklovski (2013-03-01 18:21:12+00:00)
Title: add optional callback fn arg to args.optional

Supports optional non-string values. Is backward compatible.
Before, client code would have to be something like:

val numArg : Option[String] = args.optional("num")
val num : Option[Int] = if (numArg.isDefined) Some(numArg.get.toLong) else None

After:
val num : Option[Int] = args.optional("num", _.toInt)

tests pass with
> test-only com.twitter.scalding.ArgTest
[info] Compiling 1 Scala source to /Users/tchklovski/workspace/scalding/scalding-args/target/scala-2.9.2/test-classes...
[info] No tests to run for scalding/test:test-only
[info] No tests to run for scalding-date/test:test-only
[info] No tests to run for scalding-core/test:test-only
[info] + Tool.parseArgs should
[info] + handle the empty list
[info] + accept any number of dashed args
[info] + remove empty args in lists
[info] + put initial args into the empty key
[info] + allow any number of args per key
[info] + allow any number of dashes
[info] + round trip to/from string
[info] + handle positional arguments
[info] + handle negative numbers in args
[info] + handle k, v pairs separated by an equal sign
[info] + handle multiple arguments when k, v pairs separated by an equal sign
[info] + parse optional args with and without a callback function
[info] Passed: : Total 13, Failed 0, Errors 0, Passed 13, Skipped 0
[success] Total time: 4 s, completed Mar 1, 2013 9:40:41 AM