Commit 2d047e80 authored by Ronny Wichers Schreur's avatar Ronny Wichers Schreur

added --dump-args and --restore-args options

parent 23841ad7
......@@ -56,14 +56,64 @@ coclMainWithVersionCheck currentVersion latestDefVersion latestImpVersion testA
}
| not (fst (checkVersion (versionCompare expectedVersion observedVersion) stderr))
= set_return_code (-1) world
# (commandArgs, world)
= getCommandArgs (tl [arg \\ arg <-: getCommandLine]) testArgs world
# (success, world)
= accFiles (compiler commandArgs) world
= set_return_code (if success 0(-1)) world
where
commandArgs
= if (length realArgs == 0) testArgs realArgs
realArgs
= tl [arg \\ arg <-: getCommandLine]
getCommandArgs :: [{#Char}] [{#Char}] *World -> ([{#Char}], *World)
getCommandArgs [] testArgs world
= getArgs testArgs world
getCommandArgs realArgs _ world
= getArgs realArgs world
getArgs :: [{#Char}] *World -> ([{#Char}], *World)
getArgs ["--dump-args" : commandArgs] world
# (opened, file, world)
= fopen CoclArgsFile FWriteText world
| not opened
= abort ("--dump-args " +++ CoclArgsFile +++ " could not be opened\n")
# file
= foldSt (\s -> fwritec '\n' o fwrites s) commandArgs file
# (closed, world)
= fclose file world
| not closed
= abort ("--dump-args " +++ CoclArgsFile +++ " could not be closed\n")
= (commandArgs, world)
getArgs ["--restore-args"] world
# (opened, file, world)
= fopen CoclArgsFile FReadText world
| not opened
= abort ("--restore-args " +++ CoclArgsFile +++ " could not be opened\n")
# (commandArgs, file)
= readArgs [] file
# (closed, world)
= fclose file world
| not closed
= abort ("--restore-args " +++ CoclArgsFile +++ " could not be closed\n")
= (commandArgs, world)
where
readArgs :: [{#Char}] *File -> ([{#Char}], *File)
readArgs reversedArgs file
# (arg, file)
= freadline file
| arg == ""
= (reverse reversedArgs, file)
// otherwise
= readArgs [chopNewline arg : reversedArgs] file
chopNewline :: {#Char} -> {#Char}
chopNewline s
| s.[n-1] == '\n'
= s % (0, n-2)
// otherwise
= s
where
n
= size s
CoclArgsFile :== "coclargs.txt"
import thread_message;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment