descriptive 0.0.1 → 0.0.2
raw patch · 2 files changed
+25/−12 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- descriptive.cabal +1/−1
- src/Descriptive/Options.hs +24/−11
descriptive.cabal view
@@ -1,5 +1,5 @@ name: descriptive-version: 0.0.1+version: 0.0.2 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
@@ -61,7 +61,7 @@ flag name help = consumer (d,) (\s ->- (Right (elem ("-f" <> name) s),filter (/= "-f" <> name) s))+ (Right (elem ("--" <> name) s),filter (/= "--" <> name) s)) where d = Unit (Flag name help) -- | Find an argument prefixed by -X.@@ -93,34 +93,47 @@ -- | Make a text description of the command line options. textDescription :: Description Option -> Text-textDescription = go . clean+textDescription = go False . clean where clean (And None a) = clean a clean (And a None) = clean a clean (Or a None) = clean a clean (Or None a) = clean a- clean (And a b) = And (clean a) (clean b)- clean (Or a b) = Or (clean a) (clean b)+ clean (And a b) =+ And (clean a)+ (clean b)+ clean (Or a b) =+ Or (clean a)+ (clean b) clean a = a- go d =+ go inor d = case d of Unit o -> textOpt o Bounded min' _ d' ->- "[" <> go d' <> "]" <>+ "[" <> go inor d' <> "]" <> if min' == 0 then "*" else "+"- And a b -> go a <> " " <> go b- Or a b -> "(" <> go a <> "|" <> go b <> ")"+ And a b -> go inor a <> " " <> go inor b+ Or a b ->+ (if inor+ then ""+ else "(") <>+ go True a <>+ "|" <>+ go True b <>+ (if inor+ then ""+ else ")") Sequence xs -> T.intercalate " "- (map go xs)- Wrap o d' -> textOpt o <> " " <> go d'+ (map (go inor) xs)+ Wrap o d' -> textOpt o <> " " <> go inor d' None -> "" -- | Make a text description of an option. textOpt :: Option -> Text textOpt (AnyString t) = T.map toUpper t textOpt (Constant t) = t-textOpt (Flag t _) = "-f" <> t+textOpt (Flag t _) = "--" <> t textOpt (Arg t _) = "-" <> t <> " <...>" textOpt (Prefix t _) = "-" <> t <> "<...>"