Skip to content

Commit

Permalink
Merge pull request #494 from smelc/smelc/allow-brief-renderer-tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
HuwCampbell authored Nov 6, 2024
2 parents 84c7e25 + 2d25ad2 commit 19df94f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Options/Applicative.hs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ module Options.Applicative (
helpLongEquals,
helpShowGlobals,
helpIndent,
briefHangPoint,
defaultPrefs,

-- * Completions
Expand Down
7 changes: 6 additions & 1 deletion src/Options/Applicative/Builder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ module Options.Applicative.Builder (
helpLongEquals,
helpShowGlobals,
helpIndent,
briefHangPoint,
prefs,
defaultPrefs,

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

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


-- | Create a `ParserPrefs` given a modifier
Expand All @@ -597,7 +601,8 @@ prefs m = applyPrefsMod m base
, prefColumns = 80
, prefHelpLongEquals = False
, prefHelpShowGlobal = False
, prefTabulateFill = 24 }
, prefTabulateFill = 24
, prefBriefHangPoint = 35 }

-- Convenience shortcuts

Expand Down
2 changes: 1 addition & 1 deletion src/Options/Applicative/Help/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ parserUsage pprefs p progn =
hsep
[ pretty "Usage:",
pretty progn,
hangAtIfOver 9 35 (extractChunk (briefDesc pprefs p))
hangAtIfOver 9 (prefBriefHangPoint pprefs) (extractChunk (briefDesc pprefs p))
]

-- | Peek at the structure of the rendered tree within.
Expand Down
3 changes: 2 additions & 1 deletion src/Options/Applicative/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ data ParserPrefs = ParserPrefs
, prefHelpShowGlobal :: Bool -- ^ when displaying subparsers' usage help,
-- show parent options under a "global options"
-- section (default: False)
, prefTabulateFill ::Int -- ^ Indentation width for tables
, prefTabulateFill ::Int -- ^ Indentation width for tables
, prefBriefHangPoint :: Int -- ^ Width at which to hang the brief description
} deriving (Eq, Show)

data OptName = OptShort !Char
Expand Down

0 comments on commit 19df94f

Please sign in to comment.