Files
gf-core/src/compiler/GF.hs
hallgren 3488632558 Added a preliminary "gf -server" mode.
The command "gf -server" now starts a simple HTTP server on port 41295,
providing a simple web API to the GF compiler. It currently support the
follwing operations:

  * creating new temporary directories for grammar uploads,
  * uploading grammars files for use in the GF shell,
  * executing GF shell commands, and
  * accessing static files.

This means that GF now depends on some additional networking related packages,
but they should be available and easy to install on all platforms. There is
also a new configuration flag "server" in gf.cabal, so GF will be compiled
without support for server mode if the extra packages are unavailable.

Note that running gf -server while connected to the internet can be a security
risk. To prevent unauthorized access to the rest of the system, it is
advisable to run the server in GF_RESTRICTED mode and as a user with suitably
restricted file permissions.
2011-04-13 14:58:01 +00:00

50 lines
1.4 KiB
Haskell

{-# OPTIONS -cpp #-}
module Main where
import GFC
import GFI
import GF.Data.ErrM
import GF.Infra.Option
import GF.Infra.UseIO
import Paths_gf
import Data.Version
import System.Directory
import System.Environment (getArgs)
import System.Exit
import System.IO
#ifdef mingw32_HOST_OS
import System.Win32.Console
import System.Win32.NLS
#endif
main :: IO ()
main = do
#ifdef mingw32_HOST_OS
codepage <- getACP
setConsoleCP codepage
setConsoleOutputCP codepage
enc <- mkTextEncoding ("CP"++show codepage)
hSetEncoding stdin enc
hSetEncoding stdout enc
hSetEncoding stderr enc
#endif
args <- getArgs
case parseOptions args of
Ok (opts,files) -> do curr_dir <- getCurrentDirectory
lib_dir <- getLibraryDirectory opts
mainOpts (fixRelativeLibPaths curr_dir lib_dir opts) files
Bad err -> do hPutStrLn stderr err
hPutStrLn stderr "You may want to try --help."
exitFailure
mainOpts :: Options -> [FilePath] -> IO ()
mainOpts opts files =
case flag optMode opts of
ModeVersion -> putStrLn $ "Grammatical Framework (GF) version " ++ showVersion version
ModeHelp -> putStrLn helpMessage
ModeInteractive -> mainGFI opts files
ModeRun -> mainRunGFI opts files
ModeServer -> mainServerGFI opts files
ModeCompiler -> dieIOE (mainGFC opts files)