diff options
author | Paul Phillips <paulp@improving.org> | 2011-04-07 17:43:41 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-04-07 17:43:41 +0000 |
commit | caee04079fb8ed40a1458cf24649fad9d80a85c1 (patch) | |
tree | bc8fa7a77760582d91f135dcf72ff15a89ea4984 /src/library | |
parent | 42dbce32957e048173c1749697d6bf9273581030 (diff) | |
download | scala-caee04079fb8ed40a1458cf24649fad9d80a85c1.tar.gz scala-caee04079fb8ed40a1458cf24649fad9d80a85c1.tar.bz2 scala-caee04079fb8ed40a1458cf24649fad9d80a85c1.zip |
Made power mode more configurable.
long-term configuration answer, but what I have any chance of doing
before 2.9 ships.
// file to interpret when entering power mode instead of default
-Dscala.repl.power.initcode=/path/to/file // file holding banner to
display instead of default -Dscala.repl.power.banner=/path/to/file
No review.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/sys/BooleanProp.scala | 2 | ||||
-rw-r--r-- | src/library/scala/sys/Prop.scala | 5 | ||||
-rw-r--r-- | src/library/scala/sys/PropImpl.scala | 2 |
3 files changed, 9 insertions, 0 deletions
diff --git a/src/library/scala/sys/BooleanProp.scala b/src/library/scala/sys/BooleanProp.scala index 85719103de..e940990785 100644 --- a/src/library/scala/sys/BooleanProp.scala +++ b/src/library/scala/sys/BooleanProp.scala @@ -46,6 +46,8 @@ object BooleanProp { def setValue[T1 >: Boolean](newValue: T1): Boolean = value def get: String = "" + value val clear, enable, disable, toggle = () + def option = if (isSet) Some(value) else None + protected def zero = false } diff --git a/src/library/scala/sys/Prop.scala b/src/library/scala/sys/Prop.scala index fa866085c0..33b88f119f 100644 --- a/src/library/scala/sys/Prop.scala +++ b/src/library/scala/sys/Prop.scala @@ -53,6 +53,10 @@ trait Prop[+T] { */ def get: String + /** Some(value) if the property is set, None otherwise. + */ + def option: Option[T] + /** Removes the property from the underlying map. */ def clear(): Unit @@ -75,6 +79,7 @@ object Prop { def apply(key: String): Prop[T] } + implicit object FileProp extends CreatorImpl[java.io.File](s => new java.io.File(s)) implicit object StringProp extends CreatorImpl[String](s => s) implicit object IntProp extends CreatorImpl[Int](_.toInt) implicit object DoubleProp extends CreatorImpl[Double](_.toDouble) diff --git a/src/library/scala/sys/PropImpl.scala b/src/library/scala/sys/PropImpl.scala index 888e9d7327..b84553ea22 100644 --- a/src/library/scala/sys/PropImpl.scala +++ b/src/library/scala/sys/PropImpl.scala @@ -31,6 +31,8 @@ private[sys] class PropImpl[+T](val key: String, valueFn: String => T) extends P else "" def clear(): Unit = underlying -= key + def option: Option[T] = if (isSet) Some(value) else None + def or[T1 >: T](alt: => T1): T1 = if (isSet) value else alt /** The underlying property map, in our case always sys.props */ protected def underlying: mutable.Map[String, String] = scala.sys.props |