8

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 .

jub0bs
  • 60,866
  • 25
  • 183
  • 186
d8d0d65b3f7cf42
  • 2,597
  • 15
  • 28

1 Answers1

5

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.

kosmikus
  • 19,549
  • 3
  • 51
  • 66