diff --git a/brittany.cabal b/brittany.cabal index ad87944..89f37c7 100644 --- a/brittany.cabal +++ b/brittany.cabal @@ -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 diff --git a/source/library/Language/Haskell/Brittany/Internal.hs b/source/library/Language/Haskell/Brittany/Internal.hs index 06cbb63..fc2f099 100644 --- a/source/library/Language/Haskell/Brittany/Internal.hs +++ b/source/library/Language/Haskell/Brittany/Internal.hs @@ -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) diff --git a/source/library/Language/Haskell/Brittany/Main.hs b/source/library/Language/Haskell/Brittany/Main.hs index e599fc2..44eac1d 100644 --- a/source/library/Language/Haskell/Brittany/Main.hs +++ b/source/library/Language/Haskell/Brittany/Main.hs @@ -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