definition:
|
processArgsAndStart :: ReplState -> [String] -> IO ()
processArgsAndStart rst []
| quit rst = cleanUpAndExitRepl rst
| otherwise = do
writeVerboseInfo rst 1 (ccBanner (compiler rst))
unless (null (usingOption rst)) $ writeVerboseInfo rst 1 $
"(using " ++ usingOption rst ++ ")\n"
writeVerboseInfo rst 1 $
"Type \":h\" for help (contact: " ++ ccEmail (compiler rst) ++ ")"
when (currMod rst == "Prelude") $ do
writeVerboseInfo rst 1 $ "Compiling Prelude..."
processCompile (reduceVerbose rst) "Prelude" >> return ()
repLoop rst
processArgsAndStart rst (arg:args)
-- ignore empty arguments which can be provided by single or double quotes
| null arg
= processArgsAndStart rst args
-- ignore '--nocypm|-n' or '--noreadline'
-- (since they already processed by separate script to invoke the REPL)
| arg == "--using" && not (null args)
= processArgsAndStart rst { usingOption = head args } (tail args)
| arg `elem` ["-n", "--nocypm", "--noreadline"]
= processArgsAndStart rst args
| arg == "-h" || arg == "--help" || arg == "-?"
= printHelp rst >> cleanUpAndExitRepl rst
| arg == "-q" || arg == "--quiet"
= processArgsAndStart rst { verbose = 0 } args
| arg == "-V" || arg == "--version"
= do putStrLn (ccBanner (compiler rst))
processArgsAndStart rst { quit = True} args
| arg `elem` versionOpts -- process all version options and quit:
= do let (vopts,mopts) = partition (`elem` versionOpts) args
if null mopts
then do system $ unwords (ccExec (compiler rst) : arg : vopts)
cleanUpAndExitRepl rst
else writeErrorMsg ("illegal options: " ++ unwords mopts)
| isCommand arg = do
let (cmdargs, more) = break isCommand args
mbrst <- processCommand rst (tail (unwords (arg:cmdargs)))
maybe (printHelp rst) (\rst' -> processArgsAndStart rst' more) mbrst
| otherwise
= writeErrorMsg ("unknown option: " ++ unwords (arg:args)) >> printHelp rst
where
versionOpts = ["--compiler-name", "--numeric-version", "--base-version"]
|