diff options
Diffstat (limited to 'src/Text/Pandoc/App')
-rw-r--r-- | src/Text/Pandoc/App/CommandLineOptions.hs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs index 4253620f7..14f665aa9 100644 --- a/src/Text/Pandoc/App/CommandLineOptions.hs +++ b/src/Text/Pandoc/App/CommandLineOptions.hs @@ -786,7 +786,10 @@ options = , Option "D" ["print-default-template"] (ReqArg - (\arg _ -> do + (\arg opt -> do + let write = case optOutputFile opt of + Just f -> UTF8.writeFile f + Nothing -> UTF8.hPutStr stdout templ <- runIO $ do setUserDataDir Nothing getDefaultTemplate arg @@ -794,7 +797,7 @@ options = Right "" -> -- e.g. for docx, odt, json: E.throwIO $ PandocCouldNotFindDataFileError ("templates/default." ++ arg) - Right t -> UTF8.hPutStr stdout t + Right t -> write t Left e -> E.throwIO e exitSuccess) "FORMAT") @@ -802,18 +805,24 @@ options = , Option "" ["print-default-data-file"] (ReqArg - (\arg _ -> do + (\arg opt -> do + let write = case optOutputFile opt of + Just f -> BS.writeFile f + Nothing -> BS.hPutStr stdout runIOorExplode $ - readDefaultDataFile arg >>= liftIO . BS.hPutStr stdout + readDefaultDataFile arg >>= liftIO . write exitSuccess) "FILE") "" -- "Print default data file" , Option "" ["print-highlight-style"] (ReqArg - (\arg _ -> do + (\arg opt -> do + let write = case optOutputFile opt of + Just f -> B.writeFile f + Nothing -> B.putStr sty <- fromMaybe pygments <$> lookupHighlightStyle arg - B.putStr $ encodePretty' + write $ encodePretty' defConfig{confIndent = Spaces 4 ,confCompare = keyOrder (map T.pack |