-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How does one inherit or reuse options? #132
Comments
I was able to combine two parsers into one set of options, see http://stackoverflow.com/a/43001193/123094, but that is far from ideal. I'd like to be able to actually inherit a parser from another or combine them in some way that produces a single |
@i think the final parser needs to be a union of all the types that would eventually be parsed so you could split the "config" type up (an abstract type) if you want to but they need to come together at some point in the lowest level class. You could then just compose things based on passing around the parser instance and importing the dsl functions to "add" a component's options prior to the actual parsing. // Unit signals we are mutating
def addOptions(op: scopt.OptionParser[FinalType]): Unit = {
import op._
cmd("blah")
note("blah")
...
} Having said that you could also probably pull the option processing out of the class entirely. |
any idea of how to solve this issue? |
just do as described above, there are a couple methods. The parser object has a DSL that mutates internal structures so write a function that takes the parser object and import those DSL functions. The rest of the function uses those DSL functions to “add” your reusable parser options. There are a couple of other issues that covers this as well. Because of the dsl design, you do not declare options outside the context of a parser object. |
is it possible to have a minimal complete working example, please? |
Released scopt 4.0.0-RC2 with more composable OParser. See http://eed3si9n.com/scopt4 for details. |
enabled blurring for subbuilders
Forgive a scala noob, this is probably trivial and is basically the unanswered SO http://stackoverflow.com/questions/34026943/extending-scopt-optionparser-in-scala.
I have some base options:
I'd like to extend Job along with Opts.
So far I'm stuck here, this signature below is
String, SplineOpts -> Opts
, which is wrong, I wantSplineOpts
.Maybe there's an overall better strategy for adding more options than a base and parsing them?
The text was updated successfully, but these errors were encountered: