Created
May 27, 2016 01:49
-
-
Save natechols/58dab6ba62b04b778d4cbed4c9276e70 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
import scopt.OptionParser | |
case class BaseConfig(host: String, port: Int) | |
trait BaseParser { self: OptionParser[BaseConfig] => | |
opt[String]("host") action { (x, c) => | |
c.copy(host = x) | |
} text "Hostname of smrt server" | |
opt[Int]("port") action { (x, c) => | |
c.copy(port = x) | |
} text "Services port on smrt server" | |
} | |
object BaseProgram { | |
lazy val parser = new OptionParser[BaseConfig]("basic-config") with BaseParser { | |
head("This is the basic program", "0.0.1") | |
} | |
} | |
case class ExtendedConfig(host: String, port: Int, uiPort: Int) | |
trait ExtendedParser { self: OptionParser[ExtendedConfig] => | |
opt[Int]("ui-port") action { (x, c) => | |
c.copy(uiPort = x) | |
} text "GUI port on smrt server" | |
} | |
object ExtendedProgram { | |
lazy val parser = new OptionParser[ExtendedConfig]("extended-config") with BaseParser with ExtendedParser { | |
head("This is the more fully-featured program") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This fails: