Skip to content

Commit

Permalink
pandoc-cli: Refer printing of version info to the Lua interpreter
Browse files Browse the repository at this point in the history
The Lua interpreter no longer terminates when called with `-v` or
`--version` arguments, thus improving compatibility with the default
`lua` interpreter program.
  • Loading branch information
tarleb committed Jun 28, 2024
1 parent 59cc5c3 commit 522302a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pandoc-cli/src/pandoc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import Text.Pandoc.App ( convertWithOpts, defaultOpts, options
import Text.Pandoc.Error (handleError)
import System.Exit (exitSuccess)
import Data.Monoid (Any(..))
import Control.Monad (when)
import PandocCLI.Lua
import PandocCLI.Server
import qualified Text.Pandoc.UTF8 as UTF8
Expand Down Expand Up @@ -52,16 +51,16 @@ main = E.handle (handleError . Left) $ do
let hasVersion = getAny $ foldMap
(\s -> Any (s == "-v" || s == "--version"))
(takeWhile (/= "--") rawArgs)
when hasVersion versionInfo
let versionOr action = if hasVersion then versionInfo else action
case prg of
"pandoc-server.cgi" -> runCGI
"pandoc-server" -> runServer rawArgs
"pandoc-server.cgi" -> versionOr runCGI
"pandoc-server" -> versionOr $ runServer rawArgs
"pandoc-lua" -> runLuaInterpreter prg rawArgs
_ ->
case rawArgs of
"lua" : args -> runLuaInterpreter "pandoc lua" args
"server": args -> runServer args
args -> do
"server": args -> versionOr $ runServer args
args -> versionOr $ do
engine <- getEngine
res <- parseOptionsFromArgs options defaultOpts prg args
case res of
Expand Down

0 comments on commit 522302a

Please sign in to comment.