Switch to butcher-2.0

ghc92
Lennart Spitzner 2022-12-17 14:43:57 +01:00
parent e03ab8425b
commit dc008800e7
3 changed files with 9 additions and 7 deletions

View File

@ -40,7 +40,7 @@ common library
build-depends:
, aeson ^>= 2.0.1
, base ^>= 4.15.0
, butcher ^>= 1.3.3
, butcher ^>= 2.0.0
, bytestring ^>= 0.10.12
, cmdargs ^>= 0.10.21
, containers ^>= 0.6.4

View File

@ -114,8 +114,9 @@ extractCommentConfigs anns (TopLevelDeclNameMap declNameMap) = do
, ( "yaml-config-document"
, \s -> "{" `isPrefixOf` dropWhile (== ' ') s
, Butcher.addCmdPart (Butcher.varPartDesc "yaml-config-document")
$ fmap (\lconf -> (mempty { _conf_layout = lconf }, ""))
. either (const Nothing) Just
$ either
(\_ -> Butcher.Failure Nothing)
(\lconf -> Butcher.Success (mempty { _conf_layout = lconf }) "")
. Data.Yaml.decodeEither'
. Data.ByteString.Char8.pack
-- TODO: use some proper utf8 encoder instead?
@ -173,7 +174,7 @@ extractCommentConfigs anns (TopLevelDeclNameMap declNameMap) = do
conf <- configParser
Butcher.addCmdImpl (InlineConfigTargetModule, conf)
lineConfigss <- configLiness `forM` \(k, ss) -> do
r <- ss `forM` \s -> case Butcher.runCmdParserSimple s parser of
r <- ss `forM` \s -> case Butcher.runCmdParserSimpleString s parser of
Left err -> Left $ (err, s)
Right c -> Right $ c
pure (k, r)

View File

@ -64,7 +64,7 @@ mainWith :: String -> [String] -> IO ()
mainWith progName args =
Environment.withProgName progName
. Environment.withArgs args
$ mainFromCmdParserWithHelpDesc mainCmdParser
$ mainFromCmdParser mainCmdParser
helpDoc :: PP.Doc
helpDoc = PP.vcat $ List.intersperse
@ -133,8 +133,9 @@ licenseDoc = PP.vcat $ List.intersperse
]
mainCmdParser :: CommandDesc () -> CmdParser Identity (IO ()) ()
mainCmdParser helpDesc = do
mainCmdParser :: CmdParser Identity (IO ()) ()
mainCmdParser = do
helpDesc <- peekCmdDesc
addCmdSynopsis "haskell source pretty printer"
addCmdHelp $ helpDoc
-- addCmd "debugArgs" $ do