packages feed

optparse-applicative-simple 1.0.2 → 1.0.3

raw patch · 2 files changed

+21/−1 lines, 2 files

Files

library/OptparseApplicative/Simple/Parser.hs view
@@ -2,7 +2,9 @@ (   Parser,   argument,+  showableArgument,   lenientArgument,+  showableLenientArgument, ) where @@ -44,6 +46,17 @@       foldMap (A.help . C.unpack) description <>       foldMap (\(value, text) -> A.value value <> A.showDefaultWith (const (C.unpack text))) defaultValue +showableArgument+  :: Show a+  => Text -- ^ Long name+  -> Maybe Char -- ^ Possible short name+  -> Maybe Text -- ^ Possible description+  -> Maybe a -- ^ Possible default value+  -> B.Parser a -- ^ Attoparsec parser of the value. The \"attoparsec-data\" package provides such parsers for a lot of standard types+  -> A.Parser a+showableArgument longName shortName description defaultValue parser =+  argument longName shortName description (fmap (\ x -> (x, fromString (show x))) defaultValue) parser+ {-| Same as 'argument', only provided with a default parser. -}@@ -58,3 +71,10 @@       foldMap A.short shortName <>       foldMap (A.help . C.unpack) description <>       foldMap (\(value, text) -> A.value value <> A.showDefaultWith (const (C.unpack text))) defaultValue++{-|+Same as 'showableArgument', only provided with a default parser.+-}+showableLenientArgument :: (D.LenientParser a, Show a) => Text -> Maybe Char -> Maybe Text -> Maybe a -> A.Parser a+showableLenientArgument longName shortName description defaultValue =+  lenientArgument longName shortName description (fmap (\ x -> (x, fromString (show x))) defaultValue)
optparse-applicative-simple.cabal view
@@ -1,7 +1,7 @@ name:   optparse-applicative-simple version:-  1.0.2+  1.0.3 category:   CLI, Parsing, Options synopsis: