packages feed

optima 0.1 → 0.1.1

raw patch · 2 files changed

+19/−4 lines, 2 files

Files

library/Optima.hs view
@@ -8,6 +8,7 @@   -- * Param   Param,   value,+  switch,   -- * Value   Value,   explicitlyParsed,@@ -19,7 +20,7 @@   defaultless,   -- * ValueFormat   ValueFormat,-  enum,+  formattedByEnum,   unformatted, ) where@@ -49,6 +50,11 @@ newtype Param a = Param (Maybe Char -> Text -> Optparse.Parser a)  {-|+Parameter product, which gets resolved by prefixing the names+-}+newtype ProductParam a = ProductParam (Text -> Optparse.Parser a)++{-| Parameter value parser. -} newtype Value a = Value (Attoparsec.Parser a)@@ -129,7 +135,16 @@       paramHelp description format <>       defaultValue def +{-|+A parameter with no value, the presence of which is interpreted as 'True'.+-}+switch :: Text {-^ Description. Can be empty -} -> Param Bool+switch description =+  Param (\ shortName longName ->+    Optparse.switch+      (longParamName longName <> foldMap Optparse.short shortName <> paramHelp description UnspecifiedFormat)) + -- ** Value ------------------------- @@ -174,8 +189,8 @@ {-| Derive value format specification from the Enum instance. -}-enum :: (Bounded a, Enum a, Show a) => ValueFormat a-enum = let+formattedByEnum :: (Bounded a, Enum a, Show a) => ValueFormat a+formattedByEnum = let   values = enumFromTo minBound (asTypeOf maxBound (descriptionToA description))   descriptionToA = undefined :: ValueFormat a -> a   description = EnumValueFormat (fmap (TextBuilder.string . show) values)
optima.cabal view
@@ -1,5 +1,5 @@ name: optima-version: 0.1+version: 0.1.1 category: CLI, Parsing, Options synopsis: Simple command line interface arguments parser homepage: https://github.com/metrix-ai/optima