Skip to content

Commit f05d07a

Browse files
committed
Main: Use prettyprinter package for help text
optparse-applicative-0.18 introduces a breaking change which requires using the prettyprinter package for help text See: https://github.com/pcapriotti/optparse-applicative/releases/tag/0.18.0 Signed-off-by: hololeap <[email protected]>
1 parent 5f1b3c0 commit f05d07a

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

exe/Main.hs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ module Main (main) where
66
import Control.Applicative.Combinators
77
import qualified Control.Applicative.Combinators.NonEmpty as CNE
88
import Control.Monad
9-
import Data.Bitraversable
109
import Data.Monoid (Endo(..))
1110
import qualified Options.Applicative as Opt
1211
import qualified Options.Applicative.Help as Opt
12+
import qualified Prettyprinter as PP
1313
import qualified Text.Parsec as P
1414
import qualified Text.Parsec.String as P
1515
import qualified Distribution.Verbosity as V
@@ -153,21 +153,20 @@ globalParser = Opt.info (Opt.helper <*> parser) infoMod
153153
. P.runParser verbosityString () "command line option"
154154

155155
err :: P.ParseError -> String
156-
err _ = ($ "") $ Opt.displayS $ Opt.renderCompact $ Opt.extractChunk $ Opt.vsepChunks
157-
[ Opt.stringChunk "Takes a number (0-3) or one of the following values:"
158-
, Opt.tabulate
159-
#if MIN_VERSION_optparse_applicative(0,17,0)
160-
(Opt.prefColumns Opt.defaultPrefs)
161-
#endif
162-
=<< traverse (bitraverse Opt.stringChunk Opt.stringChunk)
163-
[ ("silent", "No output")
164-
, ("normal", "Default verbosity")
165-
, ("verbose", "Increased verbosity")
166-
, ("deafening", "Maximum verbosity")
167-
]
168-
]
169-
170-
156+
err _ = show $ PP.vsep
157+
[ PP.pretty "Takes a number (0-3) or one of the following values:"
158+
, PP.hsep
159+
[ PP.vsep $ PP.pretty . (++ ":") . fst <$> verbs
160+
, PP.vsep $ PP.pretty . snd <$> verbs
161+
]
162+
]
163+
164+
verbs =
165+
[ ("silent", "No output")
166+
, ("normal", "Default verbosity")
167+
, ("verbose", "Increased verbosity")
168+
, ("deafening", "Maximum verbosity")
169+
]
171170

172171
-----------------------------------------------------------------------
173172
-- List

hackport.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,7 @@ executable hackport
883883
, optparse-applicative
884884
, parsec
885885
, parser-combinators
886+
, prettyprinter
886887
, process
887888
other-modules: Paths_hackport
888889
other-extensions:

0 commit comments

Comments
 (0)