diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2019-03-08 08:40:31 -0800 | 
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2019-03-08 08:44:45 -0800 | 
| commit | bf4a164a6f832bbb8435c4021a6b019f8e1c29f7 (patch) | |
| tree | f700ced17976608df8cb7bf679b844a5817dfc42 /src/Text/Pandoc/App | |
| parent | a286ef2eb5e0afd3163f7214cdbbba430a61d031 (diff) | |
| download | pandoc-bf4a164a6f832bbb8435c4021a6b019f8e1c29f7.tar.gz | |
Allow -o/--output to be used with --print-*.
`--print-default-data-file`
`--print-highlighting-style`
`--print-default-template`
Note that `-o` must occur BEFORE the `--print*` command on the command line
(this is documented).
Closes #5357.
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 | 
