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

Is scopt composable? #215

frgomes opened this Issue Nov 29, 2018 · 3 comments


None yet
2 participants
Copy link

frgomes commented Nov 29, 2018

I would like to define separate parsers responsible for disjoint sets of options and compose them as needed, for example: I would define one parser per submodule of my project. When I define an application, I define which modules are needed and, doing so, the full command line parser would be made of the composition of the disjoint command line parsers defined in the modules involved. Is that scenario possible with scopt? How could that be achieved?

@frgomes frgomes changed the title Is scopt composable Is scopt composable? Nov 29, 2018


This comment has been minimized.

Copy link

eed3si9n commented Nov 29, 2018

I have a local branch I used to work on that makes scopt parsers monadic - scopt3...eed3si9n:topic/monadic
This would allow composition like this:

  lazy val groupParser1: Parser[Unit, Config] = {
    import builder._
    for {
      _ <- programName("scopt")
      _ <- head("scopt", "3.x")
      _ <- opt[Unit]('a', "alice")
      _ <- opt[Unit]('b', "bob")
      _ <- opt[Unit]("alicebob").abbr("ab").action( (x, c) => c.copy(flag = true) )
      // _ <_ help("help")
    } yield ()

This comment has been minimized.

Copy link

frgomes commented Nov 30, 2018

That looks nice! Any idea (if and) when it will be merged?


This comment has been minimized.

Copy link

eed3si9n commented Dec 28, 2018

Released scopt 4.0.0-RC2. See for details.

@eed3si9n eed3si9n closed this Dec 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment