Last active
October 5, 2018 12:27
-
-
Save Rogach/41a7331047026d7d392ec1581f4b620a to your computer and use it in GitHub Desktop.
scallop #137 bug
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
scalaVersion := "2.11.0" | |
libraryDependencies += "org.rogach" %% "scallop" % "3.1.2" |
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
import org.rogach.scallop._ | |
import java.io.{Serializable, ByteArrayOutputStream, ByteArrayInputStream, ObjectOutputStream, ObjectInputStream} | |
trait PropsArgument extends ScallopConf { | |
@transient val p: Map[String, String] = props[String]('D') | |
} | |
class TestConf(args: List[String]) extends ScallopConf(args) with Serialization with PropsArgument { | |
val apples = opt[Int]("apples") | |
verify() | |
} | |
class App(val conf: TestConf) extends Serializable { | |
val overrideMap: Map[String, String] = conf.p | |
} | |
object Test { | |
def main(args: Array[String]) { | |
val conf = new TestConf(List("-a","3","-Dkey=value")) | |
val app = new App(conf) | |
val bos = new ByteArrayOutputStream() | |
val out = new ObjectOutputStream(bos) | |
out.writeObject(app) | |
out.flush() | |
out.close() | |
val bytes = bos.toByteArray() | |
val bis = new ByteArrayInputStream(bytes); | |
val in = new ObjectInputStream(bis); | |
val app2 = in.readObject().asInstanceOf[App] | |
println(app2.conf.apples()) | |
println(app2.conf.p) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment