Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala 将命令行选项解析器与Scopt相结合_Scala_Command Line_Scopt - Fatal编程技术网

Scala 将命令行选项解析器与Scopt相结合

Scala 将命令行选项解析器与Scopt相结合,scala,command-line,scopt,Scala,Command Line,Scopt,我目前正在为命令行应用程序使用scopt。但是,我的scopt.OptionParser[Config]变得非常大。我在想,把它分解成更小的部分,然后把它们结合起来可能会更好 在阅读了文档之后,我看不出有任何方法可以做到这一点 我错过什么了吗?还是不可能?是的,它可以被分成更小的块。您可以通过将功能移动到以下特性中来实现: trait FooParser { self: OptionParser[MyArgs] => cmd("foo") ... } trait BarParser

我目前正在为命令行应用程序使用
scopt
。但是,我的
scopt.OptionParser[Config]
变得非常大。我在想,把它分解成更小的部分,然后把它们结合起来可能会更好

在阅读了文档之后,我看不出有任何方法可以做到这一点


我错过什么了吗?还是不可能?

是的,它可以被分成更小的块。您可以通过将功能移动到以下特性中来实现:

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")
  ...
}

我认为现在不可能了。你能为此打开一个GitHub问题吗?