Created
December 26, 2012 05:40
-
-
Save hochgi/4378205 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Conf extends ScallopConf(args){ | |
class BadArgsException(msg: String) extends Exception(msg) {} | |
val properties = props[String]('D') andThen | |
(_.map(_.toLowerCase)) andThen | |
(s => s.map { case s if(List("true","t","y","yes").contains(s)) => true | |
case s if(List("false","f","n","no").contains(s)) => false | |
case s => throw new BadArgsException(s + " is not a boolean value") | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One suggestion - if your
BadArgsException
would extendScallopException
instead of simpleException
, you would get a bit better error output - at least, the user wouldn't see the unneeded stack trace.