Add getWithHelpWith (#94)

This commit is contained in:
Gautier DI FOLCO 2022-04-21 17:28:58 +02:00 committed by GitHub
parent 556ce41b8b
commit 5a5a1f9d6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -1,3 +1,7 @@
1.4.8
* [Add `getWithHelpWith`](https://github.com/Gabriel439/Haskell-Optparse-Generic-Library/pull/94)
1.4.7
* [Derive `Data` instances for exported types](https://github.com/Gabriel439/Haskell-Optparse-Generic-Library/pull/89)

View File

@ -288,6 +288,7 @@ module Options.Generic (
-- * Parsers
getRecord
, getRecordWith
, getWithHelpWith
, getWithHelp
, getRecordPure
, getRecordPureWith
@ -1133,8 +1134,20 @@ getWithHelp
-- ^ Program description
-> io (a, io ())
-- ^ (options, io action to print help message)
getWithHelp desc = do
a <- getRecordWith header mempty
getWithHelp desc = getWithHelpWith desc mempty
-- | Marshal any value that implements `ParseRecord` from the commmand line
-- alongside an io action that prints the help message.
getWithHelpWith
:: (MonadIO io, ParseRecord a)
=> Text
-- ^ Program description
-> Options.PrefsMod
-- ^ 'ParserPrefs' modifiers
-> io (a, io ())
-- ^ (options, io action to print help message)
getWithHelpWith desc prefsMods = do
a <- getRecordWith header prefsMods
return (a, help)
where
header = Options.header (Data.Text.unpack desc)