Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get "leftover arguments" in optparse-applicative?

I am trying to use optparse-applicative. How can I access arguments that are not options? (From prog --foo --bar=42 baz, I want to get ["baz"])

All the the "high level" functions https://hackage.haskell.org/package/optparse-applicative-0.11.0.2/docs/Options-Applicative-Extra.html return a where I want (a,[String]).

There is some low-level function https://hackage.haskell.org/package/optparse-applicative-0.11.0.2/docs/Options-Applicative-Common.html#v:runParser but I cannot call it directly because of its type. And indeed I do want to re-use all the plumbing that is in https://hackage.haskell.org/package/optparse-applicative-0.11.0.2/docs/src/Options-Applicative-Extra.html#execParser .

like image 536
d8d0d65b3f7cf42 Avatar asked Mar 08 '15 14:03

d8d0d65b3f7cf42


1 Answers

Positional arguments are part of the parser specification. They are not returned separately by the function that runs the parser. The functions argument and strArgument can be used to add a parser for a positional argument to the specification.

like image 51
kosmikus Avatar answered Oct 29 '22 19:10

kosmikus