module Main where
import GFModes
import Operations
import UseIO
import Option
import IOGrammar
import ShellState
import Shell
import SubShell
import ShellCommands
import PShell
import JGF
import UTF8
import Today (today)
import Arch
import System (getArgs)
import Monad (foldM)
-- AR 19/4/2000 -- 11/11/2001
main :: IO ()
main = do
xs <- getArgs
let (os,fs) = getOptions "-" xs
opt j = oElem j os
st0 = optInitShellState os
case 0 of
_ | opt getHelp -> do
putStrLnFlush $ encodeUTF8 helpMsg
_ | opt forJava -> do
putStrLnFlush $ encodeUTF8 welcomeMsg
st <- useIOE st0 $
foldM (shellStateFromFiles os) st0 fs
sessionLineJ True st
return ()
_ | opt doMake -> do
case fs of
[f] -> batchCompile os f
_ -> putStrLnFlush "expecting exactly one gf file to compile"
_ | opt doBatch -> do
if opt beSilent then return () else putStrLnFlush ""
st <- useIOE st0 $
foldM (shellStateFromFiles os) st0 fs
gfBatch (initHState st)
if opt beSilent then return () else putStrLnFlush ""
return ()
_ -> do
putStrLnFlush $ welcomeMsg
st <- useIOE st0 $
foldM (shellStateFromFiles os) st0 fs
if null fs then return () else putCPU
gfInteract (initHState st)
return ()
helpMsg = unlines [
"Usage: gf