Nicholas Marshall
Nicholas Marshall

Reputation: 3238

Combining CommandLine Option Parsers with Scopt

I am currently using scopt for a Command Line Application. However My scopt.OptionParser[Config] is getting very large. I was thinking it might be nice to break it into smaller parts, and then combine them.

After reading the documentation I don't see any way of doing that.

Did I miss something? Or is it not possible?

Upvotes: 1

Views: 702

Answers (1)

Wade
Wade

Reputation: 356

Yes it can be broken into smaller chunks. You can do it by moving functionality into traits something like:

trait FooParser { self: OptionParser[MyArgs] =>
  cmd("foo")
  ...
}
trait BarParser { self: OptionParser[MyArgs] =>
  cmd("bar")
  ...
}
val fooBarParser = new OptionParser[MyArgs]("FooBar") with FooParser with BarParser {
  head("FooBar")
  ...
}

Upvotes: 2

Related Questions