summaryrefslogtreecommitdiff
path: root/src/GF.hs
blob: de288df103fd0da2eb01d3e5fddff8b467881595 (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
34
35
36
37
38
39
40
41
42
{-# 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.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
#endif
  args <- getArgs
  case parseOptions args of
    Ok (opts,files) -> mainOpts 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
      ModeCompiler    -> dieIOE (mainGFC opts files)