Skip to content

Commit 2d25ad2

Browse files
committed
Allow to tune the brief description renderer
1 parent 84c7e25 commit 2d25ad2

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

src/Options/Applicative.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ module Options.Applicative (
202202
helpLongEquals,
203203
helpShowGlobals,
204204
helpIndent,
205+
briefHangPoint,
205206
defaultPrefs,
206207

207208
-- * Completions

src/Options/Applicative/Builder.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ module Options.Applicative.Builder (
9090
helpLongEquals,
9191
helpShowGlobals,
9292
helpIndent,
93+
briefHangPoint,
9394
prefs,
9495
defaultPrefs,
9596

@@ -582,6 +583,9 @@ helpShowGlobals = PrefsMod $ \p -> p { prefHelpShowGlobal = True }
582583
helpIndent :: Int -> PrefsMod
583584
helpIndent w = PrefsMod $ \p -> p { prefTabulateFill = w }
584585

586+
-- | Set the width at which to hang the brief help text.
587+
briefHangPoint :: Int -> PrefsMod
588+
briefHangPoint php = PrefsMod $ \p -> p { prefBriefHangPoint = php }
585589

586590

587591
-- | Create a `ParserPrefs` given a modifier
@@ -597,7 +601,8 @@ prefs m = applyPrefsMod m base
597601
, prefColumns = 80
598602
, prefHelpLongEquals = False
599603
, prefHelpShowGlobal = False
600-
, prefTabulateFill = 24 }
604+
, prefTabulateFill = 24
605+
, prefBriefHangPoint = 35 }
601606

602607
-- Convenience shortcuts
603608

src/Options/Applicative/Help/Core.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ parserUsage pprefs p progn =
414414
hsep
415415
[ pretty "Usage:",
416416
pretty progn,
417-
hangAtIfOver 9 35 (extractChunk (briefDesc pprefs p))
417+
hangAtIfOver 9 (prefBriefHangPoint pprefs) (extractChunk (briefDesc pprefs p))
418418
]
419419

420420
-- | Peek at the structure of the rendered tree within.

src/Options/Applicative/Types.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ data ParserPrefs = ParserPrefs
127127
, prefHelpShowGlobal :: Bool -- ^ when displaying subparsers' usage help,
128128
-- show parent options under a "global options"
129129
-- section (default: False)
130-
, prefTabulateFill ::Int -- ^ Indentation width for tables
130+
, prefTabulateFill ::Int -- ^ Indentation width for tables
131+
, prefBriefHangPoint :: Int -- ^ Width at which to hang the brief description
131132
} deriving (Eq, Show)
132133

133134
data OptName = OptShort !Char

0 commit comments

Comments
 (0)