Skip to content

Commit

Permalink
fix prettyprinter deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
disassembler committed Jul 26, 2023
1 parent 125c272 commit 84306a0
Show file tree
Hide file tree
Showing 5 changed files with 801 additions and 26 deletions.
50 changes: 25 additions & 25 deletions bech32/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ import Options.Applicative
, showHelpOnEmpty
, (<|>)
)
import Options.Applicative.Help.Pretty
( bold, hsep, indent, text, underline, vsep )
import Paths_bech32
( version )
import Prettyprinter
import Prettyprinter.Render.Terminal
import System.IO
( BufferMode (..), Handle, hSetBuffering, stderr, stdin, stdout )

Expand Down Expand Up @@ -90,24 +90,24 @@ parse = customExecParser (prefs showHelpOnEmpty) parser
]
, footerDoc $ Just $ vsep
[ hsep
[ text "Supported encoding formats:"
, indent 0 $ text "Base16, Bech32 & Base58."
[ pretty "Supported encoding formats:"
, indent 0 $ pretty "Base16, Bech32 & Base58."
]
, text ""
, text "Examples:"
, indent 2 $ hsep [underline $ text "To", text "Bech32:"]
, indent 4 $ bold $ text "$ bech32 base16_ <<< 706174617465"
, indent 4 $ text "base16_1wpshgct5v5r5mxh0"
, text ""
, indent 4 $ bold $ text "$ bech32 base58_ <<< Ae2tdPwUPEYy"
, indent 4 $ text "base58_1p58rejhd9592uusa8pzj2"
, text ""
, indent 4 $ bold $ text "$ bech32 new_prefix <<< old_prefix1wpshgcg2s33x3"
, indent 4 $ text "new_prefix1wpshgcgeak9mv"
, text ""
, indent 2 $ hsep [underline $ text "From", text "Bech32:"]
, indent 4 $ bold $ text "$ bech32 <<< base16_1wpshgct5v5r5mxh0"
, indent 4 $ text "706174617465"
, pretty ""
, pretty "Examples:"
, indent 2 $ hsep [annotate underlined $ pretty "To", pretty "Bech32:"]
, indent 4 $ annotate bold $ pretty "$ bech32 base16_ <<< 706174617465"
, indent 4 $ pretty "base16_1wpshgct5v5r5mxh0"
, pretty ""
, indent 4 $ annotate bold $ pretty "$ bech32 base58_ <<< Ae2tdPwUPEYy"
, indent 4 $ pretty "base58_1p58rejhd9592uusa8pzj2"
, pretty ""
, indent 4 $ annotate bold $ pretty "$ bech32 new_prefix <<< old_prefix1wpshgcg2s33x3"
, indent 4 $ pretty "new_prefix1wpshgcgeak9mv"
, pretty ""
, indent 2 $ hsep [annotate underlined $ pretty "From", pretty "Bech32:"]
, indent 4 $ annotate bold $ pretty "$ bech32 <<< base16_1wpshgct5v5r5mxh0"
, indent 4 $ pretty "706174617465"
]
]

Expand All @@ -127,12 +127,12 @@ hrpArgument :: Parser HumanReadablePart
hrpArgument = argument (eitherReader reader) $ mconcat
[ metavar "PREFIX"
, helpDoc $ Just $ vsep
[ text "An optional human-readable prefix (e.g. 'addr')."
, indent 2 $ text
"- When provided, the input text is decoded from various encoding \
[ pretty "An optional human-readable prefix (e.g. 'addr')."
, indent 2 $ pretty
"- When provided, the input pretty is decoded from various encoding \
\formats and re-encoded to bech32 using the given prefix."
, indent 2 $ text
"- When omitted, the input text is decoded from bech32 to base16."
, indent 2 $ pretty
"- When omitted, the input pretty is decoded from bech32 to base16."
]
]
where
Expand Down Expand Up @@ -183,7 +183,7 @@ detectEncoding str
| otherwise = resembleBase16 <|> resembleBech32 <|> resembleBase58
where
resembleBase16 = do
guard (all isHexDigit (toLower <$> str))
guard (all isHexDigit . toLower) str
guard (even (length str))
pure Base16

Expand Down
4 changes: 3 additions & 1 deletion bech32/bech32.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ executable bech32
, bytestring
, extra
, memory
, optparse-applicative >= 0.17.0.0 && < 0.18
, optparse-applicative
, prettyprinter
, prettyprinter-ansi-terminal
, text
ghc-options:
-Wall -Wcompat -fwarn-redundant-constraints
Expand Down
3 changes: 3 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
index-state:
, hackage.haskell.org 2023-07-27T22:41:49Z

packages:
bech32/bech32.cabal
bech32-th/bech32-th.cabal
Expand Down
Loading

0 comments on commit 84306a0

Please sign in to comment.