packages feed

optparse-applicative 0.15.0.0 → 0.15.1.0

raw patch · 5 files changed

+65/−7 lines, 5 filesdep ~QuickCheck

Dependency ranges changed: QuickCheck

Files

CHANGELOG.md view
@@ -1,3 +1,13 @@+## Version 0.15.1.0 (12 Sep 2019)++- Improve printing of brief descriptions for parsers.+  Previously, the logical structure of the parser,+  such as alternative groups and segments which must+  be defined together, did not influence the layout of+  the brief description. This could lead to some help+  texts being difficult to read.  Now, we use nesting+  and forced line breaks to help improve readability.+ ## Version 0.15.0.0 (05 Jul 2019)  - Add support for GHC 8.8.1.@@ -11,7 +21,7 @@ - Improve rendering of complex nested parse structures.   Previously, brackets and parenthesis did not respect   whether or not options had to be defined together.-  Now the parse tree is more accurately represeted in+  Now the parse tree is more accurately represented in   the help text.  - Add `helpLongEquals` modifier, which will change how
README.md view
@@ -5,8 +5,8 @@ [![Hackage-Deps][hackage-deps-png]][hackage-deps]  optparse-applicative is a haskell library for parsing options on-the command line, providing a powerful [applicative] interface-for composing these options.+the command line, and providing a powerful [applicative] interface+for composing them.  optparse-applicative takes care of reading and validating the arguments passed to the command line, handling and reporting errors,
optparse-applicative.cabal view
@@ -1,5 +1,5 @@ name:                optparse-applicative-version:             0.15.0.0+version:             0.15.1.0 synopsis:            Utilities and combinators for parsing command line options description:     optparse-applicative is a haskell library for parsing options
src/Options/Applicative/Help/Core.hs view
@@ -112,7 +112,7 @@       , descHidden = False }  -- | Wrap a doc in parentheses or brackets if required.-wrap :: AltNodeType ->  (Chunk Doc, Wrapping) -> Chunk Doc+wrap :: AltNodeType -> (Chunk Doc, Wrapping) -> Chunk Doc wrap altnode (chunk, wrapping)   | altnode == MarkDefault   = fmap brackets chunk@@ -130,15 +130,17 @@   = (foldr ((<</>>) . wrap NoDefault . foldTree) mempty xs, Bare) foldTree (AltNode b xs)   = (\x -> (x, Bare))+  . fmap groupOrNestLine   . wrap b   . alt_node   . filter (not . isEmpty . fst)   . map foldTree $ xs     where+   alt_node :: [(Chunk Doc, Wrapping)] -> (Chunk Doc, Wrapping)   alt_node [n] = n   alt_node ns = (\y -> (y, Wrapped))-              . foldr (chunked (\x y -> x </> char '|' </> y) . wrap NoDefault) mempty+              . foldr (chunked altSep . wrap NoDefault) mempty               $ ns  -- | Generate a full help text for a parser.
src/Options/Applicative/Help/Pretty.hs view
@@ -1,10 +1,56 @@ module Options.Applicative.Help.Pretty   ( module Text.PrettyPrint.ANSI.Leijen   , (.$.)+  , groupOrNestLine+  , altSep   ) where -import Text.PrettyPrint.ANSI.Leijen hiding ((<$>), (<>), columns)+import           Control.Applicative+import           Data.Semigroup ((<>))++import           Text.PrettyPrint.ANSI.Leijen hiding ((<$>), (<>), columns)+import           Text.PrettyPrint.ANSI.Leijen.Internal (Doc (..), flatten) import qualified Text.PrettyPrint.ANSI.Leijen as PP +import           Prelude+ (.$.) :: Doc -> Doc -> Doc (.$.) = (PP.<$>)+++-- | Apply the function if we're not at the+--   start of our nesting level.+ifNotAtRoot :: (Doc -> Doc) -> Doc -> Doc+ifNotAtRoot f doc =+  Nesting $ \i ->+    Column $ \j ->+      if i == j+        then doc+        else f doc+++-- | Render flattened text on this line, or start+--   a new line before rendering any text.+--+--   This will also nest subsequent lines in the+--   group.+groupOrNestLine :: Doc -> Doc+groupOrNestLine =+  Union+    <$> flatten+    <*> ifNotAtRoot (line <>) . nest 2+++-- | Separate items in an alternative with a pipe.+--+--   If the first document and the pipe don't fit+--   on the line, then mandatorily flow the next entry+--   onto the following line.+--+--   The (<//>) softbreak ensures that if the document+--   does fit on the line, there is at least a space,+--   but it's possible for y to still appear on the+--   next line.+altSep :: Doc -> Doc -> Doc+altSep x y =+  group (x <+> char '|' <> line) <//> y