descriptive 0.2.0 → 0.3.0
raw patch · 2 files changed
+23/−14 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Descriptive.Options: constant :: Text -> Text -> Consumer [Text] (Option a) Text
+ Descriptive.Options: constant :: Text -> Text -> v -> Consumer [Text] (Option a) v
Files
- descriptive.cabal +1/−1
- src/Descriptive/Options.hs +22/−13
descriptive.cabal view
@@ -1,5 +1,5 @@ name: descriptive-version: 0.2.0+version: 0.3.0 synopsis: Self-describing consumers/parsers; forms, cmd-line args, JSON, etc. description: Self-describing consumers/parsers. See the README.md for more information. It is currently EXPERIMENTAL. stability: Experimental
src/Descriptive/Options.hs view
@@ -6,13 +6,17 @@ -- | Command-line options parser. module Descriptive.Options- (-- * Combinators- anyString- ,constant- ,flag+ (-- * Existence flags+ flag ,switch+ -- * Text input arguments ,prefix ,arg+ -- * Token consumers+ -- $tokens+ ,anyString+ ,constant+ -- * Special control ,stop -- * Description ,Option(..)@@ -42,7 +46,7 @@ deriving (Show,Eq) -- | If the consumer succeeds, stops the whole parser and returns--- immediately.+-- 'Stopped' immediately. stop :: Consumer [Text] (Option a) a -- ^ A parser which, when it succeeds, causes the whole parser to stop. -> Consumer [Text] (Option a) ()@@ -72,20 +76,22 @@ where d = Unit (AnyString help) -- | Consume one argument from the argument list which must match the--- given string.+-- given string, and also pops it off the argument list. constant :: Text -- ^ String. -> Text -- ^ Description.- -> Consumer [Text] (Option a) Text-constant x' desc =+ -> v+ -> Consumer [Text] (Option a) v+constant x' desc v = consumer (d,) (\s -> case s of (x:s') | x == x' ->- (Succeeded x,s')+ (Succeeded v,s') _ -> (Failed d,s)) where d = Unit (Constant x' desc) --- | Find a value flag which must succeed.+-- | Find a value flag which must succeed. Removes it from the+-- argument list if it succeeds. flag :: Text -- ^ Name. -> Text -- ^ Description. -> v -- ^ Value returned when present.@@ -99,7 +105,8 @@ ) where d = Unit (Flag name help) --- | Find a boolean flag. Always succeeds. Omission counts as 'False'.+-- | Find a boolean flag. Always succeeds. Omission counts as+-- 'False'. Removes it from the argument list if it returns True. switch :: Text -- ^ Name. -> Text -- ^ Description. -> Consumer [Text] (Option a) Bool@@ -107,7 +114,8 @@ flag name help True <|> pure False --- | Find an argument prefixed by -X.+-- | Find an argument prefixed by -X. Removes it from the argument+-- list when it succeeds. prefix :: Text -- ^ Prefix string. -> Text -- ^ Description. -> Consumer [Text] (Option a) Text@@ -119,7 +127,8 @@ Just a -> (Succeeded (T.drop (T.length pref + 1) a), delete a s)) where d = Unit (Prefix pref help) --- | Find a named argument e.g. @--name value@.+-- | Find a named argument e.g. @--name value@. Removes it from the+-- argument list when it succeeds. arg :: Text -- ^ Name. -> Text -- ^ Description. -> Consumer [Text] (Option a) Text