This has significant benefits, in that it covers off Text and ByteString
readers for free (and without dependencies) and works pretty seamlessly
with Attoparsec parsers.
May cause breakages if people are using str for type inference.
In that case, adding type signatures should fix the problem.
We can push the option name supplied into the construction of the
error message. This cleans up the `ExpectsArgError` type, while
keeping essentially all English text in one place, and allows
a user to customise this message better.
We can keep the builder API the same though using const.
Uses a Levenshtein distance to see if there's a suitable
candidate for suggestions.
Also fixes a subtle bug in bash completions, where argument
completers from deeper into the parser would have their
possibilities added to the completion.
noInterpserse was not allowing any options to occur
before arguments, and wasn't behaving as its namesake
in other parsing libraries.
Add a new policy (which is potentially useful for
applications wrapping other cli tools) allowing the
command (or subcommand) to collect all unknown options
and arguments as positionals to be passed to the
command line.
We're actually turning off redundant-constraints warnings, as we
use these so the user don't turn on metavars or use hasValue when
it doesn't make sense to do so.
Previously the entire BindP was required to pass during each call to
searchParser. Meaning that many pairs of arguments were not possible. By
being a bit more lazy in progressing through these options, and rebuilding
the BindP instead of asserting that it must be complete, we can allow for
many pairs or triples of items.
For example:
p = many $ (,) <$> argument str idm <*> argument str idm
I was mystified as to how to use execParserPure and related functions
to debug a parser, because I couldn't see where there existed a way
to specify default preferences.
Turns out such a way didn't really exist! This is much preferable
to using prefs idm directly, as the word "default" is the first
thing a user will search for, whereas I stumbled on prefs idm only
by reading the source.
`ReadM` now includes the `String ->` bit. This makes it less awkward to define
and compose readers.
This commit also makes `ReadM` work for argument readers (#106).
It should now be relatively easy to customise the appearance of the generated
help text.
For example, in #54, @amigalemming asks for a way to get rid of the usage line
when a specific error message is displayed. This is now easy to achieve:
exec :: ParserPrefs -> ParserInfo a -> IO a
exec pprefs pinfo = do
res <- execParserPure pprefs pinfo <$> getArgs
let f h | isEmpty (helpError h) = h
| otherwise = h { helpUsage = mempty }
handleParseResult (overFailure f res)