Commit bdba9b59 authored by Jurrien Stutterheim's avatar Jurrien Stutterheim

Fix parsing bug and take specified envs dir into account

parent 0409fc2e
......@@ -15,18 +15,20 @@ import ParserCombinators
:: BBArgs =
{ force_rebuild :: Bool
, proj_path :: Maybe String
, env_path :: Maybe String }
, envsdir :: Maybe String }
Start :: *World -> *World
Start world
# commandline = getCommandLine
cl = intersperse " " (tl [arg \\ arg <-: commandline])
args = concat [fromString c \\ c <- cl]
{force_rebuild=force_rebuild, proj_path=proj_path, env_path=env_path} = startPBB args
{force_rebuild=force_rebuild, proj_path=proj_path, envsdir=envsdir} = startPBB args
| isNothing proj_path = wAbort ("BatchBuild\nUse as: 'BatchBuild [--force] projectname.prj [envsdir]'\n") world
# (startup,world) = accFiles GetFullApplicationPath world
# envspath = application_path EnvsFileName
# (envs,world) = openEnvironments startup envspath world // TODO: This is where we need to insert the .env file
| isNothing proj_path = wAbort ("BatchBuild\nUse as: 'BatchBuild [--force] projectname.prj [environment.env]'\n") world
# envsdir = case envsdir of
Nothing -> application_path EnvsFileName
(Just p) -> application_path p
# (envs,world) = openEnvironments startup envsdir world // TODO: This is where we need to insert the .env file
# ((proj,ok,err),world) = accFiles (ReadProjectFile (fromJust proj_path) startup) world
| not ok || err <> "" = wAbort ("BatchBuild failed while opening project: "+++.err+++."\n") world
# (ok,logfile,world) = openLogfile (fromJust proj_path) world
......@@ -42,20 +44,17 @@ concat xss = foldr (++) [] xss
startPBB :: [.Char] -> BBArgs
startPBB args = case filter (\(xs, _) -> xs == []) (begin pBB args) of
[] -> {force_rebuild = False, proj_path = Nothing, env_path = Nothing }
[] -> {force_rebuild = False, proj_path = Nothing, envsdir = Nothing }
[(_, as)] -> as
pBB :: CParser Char BBArgs BBArgs
pBB = pForce <&> \f -> pFilename <&> \p -> pEnv <@ \e -> {force_rebuild = f, proj_path = p, env_path = e}
pBB = pForce <&> \f -> pFilename <&> \p -> pFilename <@ \e -> {force_rebuild = f, proj_path = p, envsdir = e}
pForce :: CParser Char Bool BBArgs
pForce = (sptoken (fromString "--force") <@ const True) <!> yield False
pEnv :: CParser Char (Maybe String) BBArgs
pEnv = pFilename <!> yield Nothing
pFilename :: CParser Char (Maybe String) BBArgs
pFilename = sp (<*> (satisfy (not o isWhite))) <@ Just o toString
pFilename = (sp (<+> (satisfy (not o isWhite))) <@ Just o toString) <!> yield Nothing
pinit :: .Bool *GeneralSt -> *GeneralSt
pinit force_rebuild ps
......
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