blob: 45b6ac6948eeec9a40b7f670511d5ec373cebd05 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/*-------------------------------------------------------------------------*\
** ScalaCheck **
** Copyright (c) 2007-2014 Rickard Nilsson. All rights reserved. **
** http://www.scalacheck.org **
** **
** This software is released under the terms of the Revised BSD License. **
** There is NO WARRANTY. See the file LICENSE for the full text. **
\*------------------------------------------------------------------------ */
package org.scalacheck.util
import scala.collection.Set
import org.scalacheck.Test
private[scalacheck] trait CmdLineParser {
type Elem = String
trait Opt[+T] {
val default: T
val names: Set[String]
val help: String
}
trait Flag extends Opt[Unit]
trait IntOpt extends Opt[Int]
trait FloatOpt extends Opt[Float]
trait StrOpt extends Opt[String]
class OptMap {
private val opts = new collection.mutable.HashMap[Opt[_], Any]
def apply(flag: Flag): Boolean = opts.contains(flag)
def apply[T](opt: Opt[T]): T = opts.get(opt) match {
case None => opt.default
case Some(v) => v.asInstanceOf[T]
}
def update[T](opt: Opt[T], optVal: T) = opts.update(opt, optVal)
}
val opts: Set[Opt[_]]
}
|