hslua-cli-1.4.3: Command-line interface for Lua

Copyright | Copyright © 2017-2024 Albert Krewinkel
License | MIT
Maintainer | Albert Krewinkel <tarleb@hslua.org>
Safe Haskell | None
Language | Haskell2010

HsLua.CLI

Contents

- Run scripts as program

Description

Embeddable Lua interpreter interface.

Synopsis

- runStandalone :: LuaError e => Settings e -> String -> [String] -> IO ()
- data Settings e = Settings {
  - settingsVersionInfo :: Text
  - settingsRunner :: EnvBehavior -> LuaE e () -> IO ()
  - settingsHistory :: Maybe FilePath
  }
- data EnvBehavior
  - = IgnoreEnvVars
  - | ConsultEnvVars

# Run scripts as program

runStandalone Source #

Arguments

:: LuaError e |
=> Settings e | interpreter configuration
-> String | program name (for error messages)
-> [String] | command line arguments
-> IO () |

Uses the first command line argument as the name of a script file and tries to run that script in Lua. Falls back to stdin if no file is given. Any remaining args are passed to Lua via the global table `arg`.

data Settings e Source #

Settings for the Lua command line interface.

If env vars should be ignored, and the interpreter invokes `openlibs`, then the registry key `LUA_NOENV` should be set to `true` before that function is invoked. E.g.:

    runner envBehavior action = run $ do
      when (envBehavior == IgnoreEnvVars) $ do
        pushboolean True
        setfield registryindex "LUA_NOENV"
      openlibs
      action

Constructors

Settings |

Fields

- settingsVersionInfo :: Text

  Additional version info to present to the user. The current Lua version will always be printed.

- settingsRunner :: EnvBehavior -> LuaE e () -> IO ()

  The Lua interpreter to be used; the first argument indicates whether environment variables should be consulted or ignored.

- settingsHistory :: Maybe FilePath

data EnvBehavior Source #

Whether environment variables should be consulted or ignored.

Constructors

IgnoreEnvVars |
ConsultEnvVars |

#### Instances

Instances details

Show EnvBehavior Source # |
Instance details Defined in HsLua.CLI Methods showsPrec :: Int -> EnvBehavior -> ShowS Source # show :: EnvBehavior -> String Source # showList :: [EnvBehavior] -> ShowS Source #
Eq EnvBehavior Source # |
Instance details Defined in HsLua.CLI Methods (==) :: EnvBehavior -> EnvBehavior -> Bool Source # (/=) :: EnvBehavior -> EnvBehavior -> Bool Source #