Reputation: 2653
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 .
Upvotes: 8
Views: 696
Reputation: 19657
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.
Upvotes: 6