packages feed

hslua-cli 1.2.0 → 1.3.0

raw patch · 5 files changed

+31/−38 lines, 5 filesdep ~hslua-coredep ~hslua-marshallingdep ~luaPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: hslua-core, hslua-marshalling, lua

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -2,6 +2,12 @@  `hslua-cli` uses [PVP Versioning](https://pvp.haskell.org). +## hslua-cli-1.3.0++Released 2023-03-13.++-   Require hslua-core 2.3.+ ## hslua-cli-1.2.0  Released 2022-09-27.
LICENSE view
@@ -1,7 +1,7 @@ Copyright © 1994-2022 Lua.org, PUC-Rio. Copyright © 2007-2012 Gracjan Polak Copyright © 2012-2015 Ömer Sinan Ağacan-Copyright © 2016-2022 Albert Krewinkel+Copyright © 2016-2023 Albert Krewinkel  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
app/hslua.hs view
@@ -2,9 +2,9 @@ {-# LANGUAGE TypeApplications  #-} {- | Module      : Main-Copyright   : © 2022 Albert Krewinkel+Copyright   : © 2022-2023 Albert Krewinkel License     : MIT-Maintainer  : Albert Krewinkel <albert@hslua.org>+Maintainer  : Albert Krewinkel <tarleb@hslua.org>  Re-implementation of the standard Lua interpreter. -}
hslua-cli.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.2 name:                hslua-cli-version:             1.2.0+version:             1.3.0 synopsis:            Command-line interface for Lua description:         Provides an embeddable command-line interface for Lua.                      The interface is compatible with the standard Lua@@ -11,20 +11,19 @@ license:             MIT license-file:        LICENSE author:              Albert Krewinkel-maintainer:          Albert Krewinkel <albert@hslua.org>-copyright:           © 2022 Albert Krewinkel+maintainer:          Albert Krewinkel <tarleb@hslua.org>+copyright:           © 2022-2023 Albert Krewinkel category:            Foreign build-type:          Simple extra-doc-files:     README.md                      CHANGELOG.md-tested-with:         GHC == 8.0.2-                   , GHC == 8.2.2-                   , GHC == 8.4.4+tested-with:         GHC == 8.4.4                    , GHC == 8.6.5                    , GHC == 8.8.4                    , GHC == 8.10.7                    , GHC == 9.0.2-                   , GHC == 9.2.3+                   , GHC == 9.2.5+                   , GHC == 9.4.4  source-repository head   type:                git@@ -38,7 +37,7 @@ common common-options   build-depends:       base              >= 4.9.1  && < 5                      , bytestring-                     , hslua-core        >= 2.1    && < 2.3+                     , hslua-core        >= 2.3    && < 2.4    ghc-options:         -Wall                        -Wcompat@@ -60,8 +59,8 @@   hs-source-dirs:      src   exposed-modules:     HsLua.CLI   build-depends:       base              >= 4.9.1  && < 5-                     , hslua-marshalling >= 2.1    && < 2.3-                     , lua               >= 2.1    && < 2.3+                     , hslua-marshalling >= 2.2    && < 2.4+                     , lua               >= 2.3    && < 2.4                      , text              >= 1.2    && < 2.1  executable hslua
src/HsLua/CLI.hs view
@@ -1,11 +1,10 @@-{-# LANGUAGE CPP               #-} {-# LANGUAGE LambdaCase        #-} {-# LANGUAGE OverloadedStrings #-} {- | Module      : Text.Pandoc.Lua-Copyright   : Copyright © 2017-2022 Albert Krewinkel+Copyright   : Copyright © 2017-2023 Albert Krewinkel License     : MIT-Maintainer  : Albert Krewinkel <albert@hslua.org>+Maintainer  : Albert Krewinkel <tarleb@hslua.org>  Embeddable Lua interpreter interface. -}@@ -23,16 +22,13 @@ import Data.Maybe (listToMaybe) import Data.Text (Text) import Foreign.C.String (withCString)-import Foreign.Ptr (nullPtr) import HsLua.Core (LuaE, LuaError) import System.Console.GetOpt import System.Environment (lookupEnv) import System.IO (hPutStrLn, stderr)-import qualified Lua.Auxiliary as Lua import qualified Lua.Constants as Lua import qualified Lua.Primary as Lua import qualified HsLua.Core as Lua-import qualified HsLua.Core.Types as Lua import qualified HsLua.Marshalling as Lua import qualified Data.Text as T import qualified Data.Text.IO as T@@ -137,18 +133,16 @@         Lua.rawseti (Lua.nth 2) 0     Lua.setglobal "arg" -#if MIN_VERSION_lua(2,2,1)     when (optWarnings opts) $ do       l <- Lua.state       -- turn warnings on       Lua.liftIO $ withCString "@on" $ \w -> Lua.lua_warning l w Lua.FALSE-#endif      -- Run init code.     unless (optNoEnv opts) $ do       init' <- Lua.liftIO $ lookupEnv "LUA_INIT"       (case init' of-         Just ('@' : filename) -> Lua.dofileTrace filename+         Just ('@' : filename) -> Lua.dofileTrace (Just filename)          Just cmd              -> Lua.dostring (UTF8.fromString cmd)          Nothing               -> return Lua.OK)         >>= \case@@ -159,27 +153,21 @@     mapM_ runCode (reverse $ optExecute opts)      let nargs = fromIntegral . length $ optScriptArgs opts-    result <- case optScript opts of-      -- `dofileTrace` should really accept a (Maybe FilePath)-      Just script | script /= "-" -> do-        Lua.loadfile script >>= \case+    let handleScriptResult = \case           Lua.OK -> do             mapM_ Lua.pushString (optScriptArgs opts)-            Lua.pcallTrace nargs Lua.multret-          s      -> pure s+            status <- Lua.pcallTrace nargs Lua.multret+            when (status /= Lua.OK)+              Lua.throwErrorAsException+          _      -> Lua.throwErrorAsException+    case optScript opts of+      Just script | script /= "-" -> do+        Lua.loadfile (Just script) >>= handleScriptResult       Nothing | optVersion opts || not (null (optExecute opts)) ->-        pure Lua.OK+        pure ()       _ -> do         -- load script from stdin-        l <- Lua.state-        Lua.liftIO (Lua.luaL_loadfile l nullPtr) >>= \case-          Lua.LUA_OK -> do-            mapM_ Lua.pushString (optScriptArgs opts)-            Lua.pcallTrace nargs Lua.multret-          s          -> pure $ Lua.toStatus s--    when (result /= Lua.OK)-      Lua.throwErrorAsException+        Lua.loadfile Nothing >>= handleScriptResult  -- | Code to execute on startup. data LuaCode =