在 Scala 中解析命令行参数的最佳方法是什么?我个人更喜欢不需要外部 jar 的轻量级产品. 相关: 用于解析命令行参数的Java库?李>C++ 有哪些参数解析器库? 在 C# 中解析命令行参数的最佳方式 解决方案 scop/scopt val parser = new scopt.OptionParser[Config]("scopt") { head("scopt", "3.x") opt[Int]('f', "foo") action { (x, c) => c.copy(foo = x) } text("foo is an integer property") opt[File]('o', "out") required() valueName("") action { (x, c) => c.copy(out = x) } text("out is a required file property")