2016-05-24 3 views
2

Scala(https://github.com/scallop/scallop/)を使用して、Scalaのコマンドライン引数を解析しようとしています。Scallopライブラリのカスタムコンバータ

しかし、https://github.com/scallop/scallop/wiki/Custom-convertersに示すように、引数をケースクラスに変換する例はコンパイルできません。

私はコンパイル時に2つのエラーを取得:

[error] found : org.rogach.scallop.ValueConverter[center.scala.sbk.Commands.Person]{val nameRgx: scala.util.matching.Regex; val phoneRgx: scala.util.matching.Regex} 
[error] required: String 
[error] Error occurred in an application involving default arguments. 
[error]  val person = opt[Person](personConverter) 
[error]       ^

[error] ...: could not find implicit value for parameter conv: org.rogach.scallop.ValueConverter[center.scala.sbk.Commands.Person] 
[error] Error occurred in an application involving default arguments. 
[error]  val person = opt[Person](personConverter) 
[error]       ^

はあなたの助けをありがとう!

答えて

2

文書には誤字があります。 使用

val person = opt[Person]()(personConverter) // note the parentheses 

代わりの

val person = opt[Person](personConverter) 

personConverterは暗黙の引数で渡されているので。

関連する問題