aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua/Module/System.hs
blob: 04508e461f9a8a666995e93ec9a540d44ef637ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{- |
   Module      : Text.Pandoc.Lua.Module.System
   Copyright   : © 2019-2020 Albert Krewinkel
   License     : GNU GPL, version 2 or above

   Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
   Stability   : alpha

Pandoc's system Lua module.
-}
module Text.Pandoc.Lua.Module.System
  ( pushModule
  ) where

import Foreign.Lua (Lua, NumResults)
import Foreign.Lua.Module.System (arch, env, getwd, os,
                                  with_env, with_tmpdir, with_wd)
import Text.Pandoc.Lua.Util (addFunction, addField)

import qualified Foreign.Lua as Lua

-- | Push the pandoc.system module on the Lua stack.
pushModule :: Lua NumResults
pushModule = do
  Lua.newtable
  addField "arch" arch
  addField "os" os
  addFunction "environment" env
  addFunction "get_working_directory" getwd
  addFunction "with_environment" with_env
  addFunction "with_temporary_directory" with_tmpdir
  addFunction "with_working_directory" with_wd
  return 1