Commit Graph

121 Commits

Author SHA1 Message Date
Ben Selfridge
bc29e669a5 Add Option to format long options with equals sign 2019-06-08 22:57:02 +10:00
Oleg Grenrus
ad70813194 Regenerate .travis.yml
Temporarily disable 7.0 and 7.2 jobs, as there aren't
ansi-wl-pprint-0.6.8 with 7.0/7.2 support
https://matrix.hackage.haskell.org/#/package/ansi-wl-pprint

I'll add it back, as soon as
https://github.com/feuerbach/ansi-terminal/pull/82
is decided upon
2019-05-11 00:10:23 +03:00
Huw Campbell
0b83cf1099 Use tree to filter out optionals, instead of annotating the leaves 2019-03-15 20:22:09 +11:00
Huw Campbell
68bae8de5c Push bracket and parenthesis logic into the tree
Gives better rendering for optional alternatives
2019-03-15 20:22:03 +11:00
Ben Selfridge
0f2c15ac7e Add new test cases for optional pair of arguments 2019-03-15 20:10:54 +11:00
Huw Campbell
48f4d7a743 Put inline behind an option to keep old behaviour by default 2018-09-19 19:00:07 +10:00
Huw Campbell
7b2175bfc6 Fix suggestions test 2018-06-05 14:07:25 +10:00
Huw Campbell
7facbcecd1 Add a test for bash completion after -- 2017-05-12 14:25:45 +10:00
Huw Campbell
c24d176af2 Add test for rich completions 2017-05-12 14:07:22 +10:00
Huw Campbell
0ecaeb9038 Add test to ensure completions are reachable deeper into the parse 2017-03-29 19:03:42 +11:00
Huw Campbell
5cbd039ff6 Add type sig in test 2017-03-27 16:00:42 +11:00
Huw Campbell
ddcd183dbc Rewrite str, eitherReader and maybeReader to be polymorphic over IsString.
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.
2017-03-27 15:33:26 +11:00
Huw Campbell
9c72eb9853 Add an error message for when the user does not supply an argument to an option
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.
2017-03-27 13:24:14 +11:00
Huw Campbell
d9df779685 Additional completions test 2017-03-08 19:30:56 +11:00
Huw Campbell
f66ff9b083 Put suggestions into their own ParserHelp record.
This would allow one to either delete them or not
show things like usage if there is a suggestion.
2017-03-08 19:30:56 +11:00
Huw Campbell
7f292eba34 Add a test for suggestions 2017-03-08 19:30:56 +11:00
Huw Campbell
5c48137480 Add suggestions for typos
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.
2017-03-08 19:30:56 +11:00
Huw Campbell
a675abe418 Fix noIntersperse behaviour, and add new policies.
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.
2017-02-24 19:36:29 +11:00
Huw Campbell
c050e30495 Style 2016-12-01 22:04:13 +11:00
Huw Campbell
e0b9e89cef Update README and hello example 2016-11-25 12:38:06 +11:00
Huw Campbell
739bf9ec9f Prepare for 0.13 release 2016-08-12 09:55:58 +10:00
Huw Campbell
36df57d9ae Fix warnings for GHC 8.
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.
2016-08-09 10:51:10 +10:00
Huw Campbell
021df337ed Stop exporting either (<>) function. 2016-08-08 18:19:11 +10:00
Ben Gamari
b29587c436 Split up Monoid instances into Semigroup and Monoid 2016-08-05 12:16:13 +10:00
Huw Campbell
ceac32cbac Remove tasty
Add GHC 8 tests to travis
2016-08-05 11:54:14 +10:00
Huw Campbell
ae2b1389b3 Test to ensure Missing: text doesn't include optional flags and arguments 2016-06-17 08:20:48 +10:00
Huw Campbell
b3c6f20d70 Basic grouping of subparser commands 2016-06-16 21:28:17 +10:00
Huw Campbell
162e53fbf2 Add ability to display help text for commands and subcommands if the user provides no input for them 2016-06-02 11:32:18 +10:00
Simon Jakobi
596c8568ec Bump upper bounds for some test dependencies 2016-04-01 20:06:22 +02:00
Huw Campbell
f7911c4c25 Allow more complex usage of many and some.
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
2016-02-26 16:05:30 +11:00
Herbert Valerio Riedel
85812dc8a7 Relax upper bounds on transformers(-compat)
this is needed for GHC 8+ compat
2016-01-16 23:03:41 +01:00
Huw Campbell
ca915bc2d6 Also bump process in tests 2016-01-05 18:13:40 +11:00
Huw Campbell
450e7c3f70 Ensure alternative subparsers don't carry each others contexts. 2015-10-16 11:05:08 +11:00
Huw Campbell
5b48577aa5 Replace WriterT in P Monad stack with StateT.
This allows us to enter and exit the context more easily, and reset
it when a parser is finished.
2015-10-16 11:05:08 +11:00
Huw Campbell
4e0003960e Revert "Don't show hidden options in completion" 2015-09-23 14:23:08 +10:00
Huw Campbell
3fe807febd Merge pull request #152 from pcapriotti/topic/bash-completion-hidden
Don't show hidden options in completion
2015-09-02 20:56:19 +10:00
Adam Sapek
22a71d833b Relax dependency on the process package
Version 1.3 of process package has been released and the dependency
process < 1.3 causes conflicts in some cases and can be relaxed.
2015-09-02 20:51:11 +10:00
Huw Campbell
05604268cd Don't show hidden options in completion 2015-09-02 17:29:46 +10:00
Huw Campbell
ac7c58edcb Don't need a new dependency on bifunctor, arrow with suffice 2015-08-13 14:05:23 +10:00
Huw Campbell
18ad18a027 Additional tests
Catch all pattern match removal
2015-08-12 11:26:36 +10:00
Huw Campbell
41e8b2f36c Show which arguments are missing on failure 2015-08-12 11:26:30 +10:00
Huw Campbell
71ec7f8a1d Allow unix style flag combining. ie. -xcf 2015-08-12 11:09:03 +10:00
Bryan O'Sullivan
2314d3c183 Add defaultPrefs, a default preferences value
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.
2015-04-05 21:10:35 -07:00
RyanGlScott
714c8f2ed0 Bump transformers-compat upper version bounds 2015-02-13 14:30:03 -06:00
Paolo Capriotti
14d895be8d Reverse Monoid instance for ParseError
Later errors should trump previous ones
2014-09-25 10:31:11 +01:00
Paolo Capriotti
db7c752895 Test reader failure in argument 2014-09-25 10:24:42 +01:00
Paolo Capriotti
1920c648a3 Redefine ReadM as ReaderT String Except
`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).
2014-09-24 21:55:56 +01:00
Paolo Capriotti
573e90650d Update upper bound for tasty 2014-09-12 15:27:00 +01:00
Paolo Capriotti
be207e0a72 Add traversal for help text in ParserResult
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)
2014-08-27 16:08:12 +01:00
Paolo Capriotti
2ec4121a8e Return ParserHelp from parseFailure
This makes it possible to customise the final help text without duplicating the
help generation code.
2014-08-27 15:24:51 +01:00