allow list parameter conversion
Closed this issue · 0 comments
holydrinker commented
Problem Statement
A common problem when you work with parsing arguments in scala application is parsing list arguments of basic/custom objects.
Without the feature here described, you have to write your custom converter for any list arguments. This is such common usage, so we want to expose an API to automatically convert list arguments in domain objects.
Proposed Solution
We want to write a new converter that tries to convert arguments into something
. Such something
should be convertible too. We should check for implicit converter in scope for specified something
objects and, of course, you can write your custom converter for your custom Seq
if you need it.
Usage example with basic objects:
val args = SmartArgs(Array("--artists", "DaveGrohl, SimonNeil"))
val artist = args.getAs[String]("artist") // Seq("DaveGrohl", "SimonNeil")
Usage example with custom objects:
case class Artist(name: String, surname: String)
val args = SmartArgs(Array("--artists", "(Dave-Grohl), (Simon-Neil)"))
val artist = args.getAs[Artist]("artist") // Seq(Artist(Dave, Grohl), Artist(Simon, Neil))