diff options
| author | John MacFarlane <[email protected]> | 2022-11-02 19:07:22 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-11-02 19:07:22 -0700 |
| commit | 848f6b51b25089b4267bf91280e946fc2c987e23 (patch) | |
| tree | 994c3731f57d10d1c057c93bd15f60d7ed433376 /pandoc-cli | |
| parent | 8718fab96447160486321603e9257f31ae99e4e3 (diff) | |
Text.Pandoc.App: Change `parseOptionsFromArgs` and `parseOptions`... (#8406)
They now return `Either OptInfo Opt`.
Add `OptInfo` type.
Add `handleOptInfo` function. This performs the IO actions for
things like `--version` that were previously done in `parseOptionsFromArgs`.
An argument for a `ScriptingEngine` has been added, to facilitate
printing custom templates and custom extensions for Lua filters.
(However, at this stage nothing is yet done with it.)
[API change]
Diffstat (limited to 'pandoc-cli')
| -rw-r--r-- | pandoc-cli/src/pandoc.hs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/pandoc-cli/src/pandoc.hs b/pandoc-cli/src/pandoc.hs index 3c0889d8e..6bf54bda3 100644 --- a/pandoc-cli/src/pandoc.hs +++ b/pandoc-cli/src/pandoc.hs @@ -16,7 +16,7 @@ module Main where import qualified Control.Exception as E import System.Environment (getArgs, getProgName) import Text.Pandoc.App ( convertWithOpts, defaultOpts, options - , parseOptionsFromArgs ) + , parseOptionsFromArgs, handleOptInfo ) import Text.Pandoc.Error (handleError) import qualified Text.Pandoc.UTF8 as UTF8 import System.Exit (exitSuccess) @@ -61,10 +61,12 @@ main = E.handle (handleError . Left) $ do case rawArgs of "lua" : args -> runLuaInterpreter "pandoc lua" args "server": args -> runServer args - _ -> do + args -> do engine <- getEngine - opts <- parseOptionsFromArgs options defaultOpts prg rawArgs - convertWithOpts engine opts + res <- parseOptionsFromArgs options defaultOpts prg args + case res of + Left e -> handleOptInfo engine e + Right opts -> convertWithOpts engine opts copyrightMessage :: String copyrightMessage = |
