Commit 0af08346 authored by Jurrien Stutterheim's avatar Jurrien Stutterheim
Browse files

Fix Start function

parent 9c7b1f85
......@@ -35,35 +35,35 @@ Start :: *World -> *World
Start world
# commandline = getCommandLine
# cleanhome = case getEnvironmentVariable "CLEAN_HOME" of
EnvironmentVariableUndefined -> "."
(EnvironmentVariable ch) -> ch
_ -> "."
cl = intersperse " " (tl [arg \\ arg <-: commandline])
argsrec = startPBB (concat [fromString c \\ c <- cl])
| isNothing argsrec.filename = showUsage world
# world = case getStringArg "action" of
"create" -> createProject world argsrec.filename cleanhome
"show" -> showProject world argsrec.filename cleanhome
"addpath" -> addPath world argsrec.filename cleanhome
"removepath" -> removePath world argsrec cleanhome
= case getStringArg "action" argsrec.args of
(Just "create") -> createProject world argsrec.filename cleanhome
(Just "show") -> showProject world argsrec.filename cleanhome
//(Just "addpath") -> addPath world argsrec.filename cleanhome
//(Just "removepath") -> removePath world argsrec cleanhome
_ -> buildProject world argsrec
showUsage :: !*World -> *World
showUsage world = show
[ "BatchBuild"
, "Usage: BatchBuild [--force] filename [--action=ARG] [--envsdir=ARG]"
, "--action : Execute a specific action. Possible actions:"
, " --action : Execute a specific action. Possible actions:"
, " build : Build a project (default)."
, " create : Create a basic project file for a module."
, " show : Summarize the contents of a project file."
, "--envsdir : Specify a directory where environment files can be found (defaults to 'IDEEnvs')"
, " --envsdir : Specify a directory where environment files can be found (defaults to 'IDEEnvs')"
] world
buildProject :: *World BBArgs -> *World
buildProject world {force_rebuild=force_rebuild, filename=filename, args=args}
# (startup,world) = accFiles GetFullApplicationPath world
# envsdir = case getStringArg "envsdir" args of
Nothing -> application_path EnvsFileName
(Just p) -> application_path p
_ -> application_path EnvsFileName
# (envs,world) = openEnvironments startup envsdir world
# ((proj,ok,err),world) = accFiles (ReadProjectFile (fromJust filename) startup) world
| not ok || err <> "" = wAbort ("BatchBuild failed while opening project: "+++.err+++."\n") world
......@@ -146,8 +146,8 @@ concat xss = foldr (++) [] xss
startPBB :: [.Char] -> BBArgs
startPBB args = case filter (\(xs, _) -> xs == []) (begin pBB args) of
[] -> {force_rebuild = False, filename = Nothing, args = [] }
[(_, as):_] -> as
_ -> {force_rebuild = False, filename = Nothing, args = [] }
pBB :: CParser Char BBArgs BBArgs
pBB = pForce <&> \f -> pFilename <&> \p -> <*> (sp pArgs) <@ \fs -> {force_rebuild = f, filename = p, args = fs}
......@@ -167,18 +167,19 @@ pArgs = pStringLongOpt "envsdir" <|> pBoolLongOpt "force" <|> pStringLongOpt "ac
hasFlag :: String [BBArg] -> Bool
hasFlag _ [] = False
hasFlag flag [(BBBool x):xs] = flag === x || hasFlag flag xs
hasFlag flag [_:xs] = hasFlag flag xs
getStringArg :: String [BBArg] -> Maybe String
getStringArg _ [] = Nothing
getStringArg arg [(BBString x v):xs]
getStringArg arg [BBString x v:xs]
| arg === x = Just v
| otherwise = getStringArg arg xs
getStringArg arg [_:xs] = getStringArg arg xs
getIntArg :: String [BBArg] -> Maybe Int
getIntArg _ [] = Nothing
getIntArg arg [(BBInt x v):xs]
getIntArg arg [BBInt x v:xs]
| arg === x = Just v
| otherwise = getIntArg arg xs
getIntArg arg [_:xs] = getIntArg arg xs
pNotSpace :: CParser Char [Char] a
......
Supports Markdown
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