We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The current ways to construct a CommandParser are fairly limited. It would be cool to have something like this:
CommandParser
CommandParser.fromRecord( "build" ->> BuildCommand :: "check" ->> CheckCommand :: HNil )
I'm a little fuzzy on the details, though. Ideally, this should support common and command-specific options, e.g.
cli-app --config /home/lars/.local/cli-app.conf build --session HOL
Maybe something like this?
CommandParser.fromRecord[Common] { common => "build" ->> BuildCommand(common) :: "check" ->> CheckCommand(common) :: HNil }
... where the return type of *Command is some Parser[T].
*Command
Parser[T]
The text was updated successfully, but these errors were encountered:
I just realized one could possibly build that on top of the existing primitives.
case class Common(x: Int = 3, y: String = "bla") case class Command[T](@Recurse common: Common, @Recurse specific: T) def parseAux[T, Aux](args: List[String])(implicit aux: Parser.Aux[T, Aux]) = CaseApp.parse[Command[T]](args) // implicit not found when trying to define this directly, needs `parseAux` def parseCmd[T : Parser](args: List[String]) = parseAux(args)(Parser[T]) case class Cmd1(lol: String = "foo") parseCmd[Cmd1](List("--lol", "fooo", "-x", "3"))
And then build some implicits recursing over a record, constructing these composite parsers.
Sorry, something went wrong.
I've been using a workaround for that too, in coursier: https://github.com/coursier/coursier/blob/b4dd43e03c478fb1d72fe49999751f9cf6e8e6be/cli/src/main/scala-2.11/coursier/cli/Coursier.scala.
I'd like to have something along the lines of your first example work too.
No branches or pull requests
The current ways to construct a
CommandParser
are fairly limited. It would be cool to have something like this:I'm a little fuzzy on the details, though. Ideally, this should support common and command-specific options, e.g.
Maybe something like this?
... where the return type of
*Command
is someParser[T]
.The text was updated successfully, but these errors were encountered: