Advertisement
edartuz

scala_getargs

Mar 17th, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.68 KB | None | 0 0
  1. package ul
  2.  
  3. trait GetArgs extends Props {
  4.  
  5.     def argsParse(args: Array[String], sep:String = "=") {
  6.         for (a <- args) {
  7.             val as = a.split(sep)
  8.             if (as.length <= 2) {
  9.                 argFind(as(0)) match {
  10.                     case Some(attr) =>
  11.                         try {
  12.                             props.updateString(attr.tag, if (as.length == 2) as(1) else "true")
  13.                         } catch { case _:Throwable => }
  14.                     case None =>
  15.                 }
  16.             }
  17.         }
  18.     }
  19.    
  20.     def argFind(name:String, sep:String = ";"):Option[PropAttr] =
  21.         props.attrs.find( _.name.split(sep).contains(name));
  22.    
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement