Skip to content

Commit

Permalink
Add --quiet option for dhall decode (#1803)
Browse files Browse the repository at this point in the history
This is intended primarily for investigating decoding performance.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
sjakobi and mergify[bot] authored May 22, 2020
1 parent ae4d32b commit e9a94b9
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions dhall/src/Dhall/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ data Mode
, followSymlinks :: Bool
}
| Encode { file :: Input, json :: Bool }
| Decode { file :: Input, json :: Bool }
| Decode { file :: Input, json :: Bool, quiet :: Bool }
| Text { file :: Input }
| DirectoryTree { file :: Input, path :: FilePath }
| SyntaxTree { file :: Input }
Expand Down Expand Up @@ -263,7 +263,7 @@ parseMode =
Convert
"decode"
"Decode a Dhall expression from binary"
(Decode <$> parseFile <*> parseJSONFlag)
(Decode <$> parseFile <*> parseJSONFlag <*> parseQuiet)
<|> subcommand
Miscellaneous
"repl"
Expand Down Expand Up @@ -380,7 +380,7 @@ parseMode =
parseQuiet =
Options.Applicative.switch
( Options.Applicative.long "quiet"
<> Options.Applicative.help "Don't print the inferred type"
<> Options.Applicative.help "Don't print the result"
)

parseInplace = fmap f (optional p)
Expand Down Expand Up @@ -822,9 +822,15 @@ command (Options {..}) = do
Dhall.Core.throws (Dhall.Binary.decodeExpression bytes)


let doc = Dhall.Pretty.prettyCharacterSet characterSet (Dhall.Core.renote expression :: Expr Src Import)
if quiet
then return ()
else do
let doc =
Dhall.Pretty.prettyCharacterSet
characterSet
(Dhall.Core.renote expression :: Expr Src Import)

renderDoc System.IO.stdout doc
renderDoc System.IO.stdout doc

Text {..} -> do
expression <- getExpression file
Expand Down

0 comments on commit e9a94b9

Please sign in to comment.