Commit ebb0e9c8 authored by Jurrien Stutterheim's avatar Jurrien Stutterheim

Improve cpm parser

parent 00e0e40d
......@@ -50,12 +50,11 @@ spstrtok :: (String -> CParser Char [Char] a)
spstrtok = sptoken o fromString
pProject :: CParser Char CpmAction a
pProject = spstrtok "project" &> pNotSpace <&> \pn -> pProjectAction <@ Project (toString pn)
where pProjectAction = spstrtok "create" <@ const CreateProject
<|> spstrtok "show" <@ const ShowProject
pProject = spstrtok "project" &> pNotSpace <&> \pn -> (pProjectAction <!> yield ProjectHelp) <@ Project (toString pn)
where pProjectAction = spstrtok "create" <@ const CreateProject
<|> spstrtok "show" <@ const ShowProject
<|> spstrtok "build" &> pForce <&> \ f-> pIDEEnvs <@ BuildProject f
<|> spstrtok "path" &> pPathAction <@ ProjectPath
<!> yield ProjectHelp
<|> spstrtok "path" &> pPathAction <@ ProjectPath
pPathAction = spstrtok "add" &> pNotSpace <@ AddPathAction o toString
<|> spstrtok "remove" &> pNotSpace <@ RemovePathAction o toString
......@@ -66,9 +65,8 @@ pIDEEnvs :: CParser Char String a
pIDEEnvs = spstrtok "--envs" &> (<?> (spsymbol '=')) &> pNotSpace <@ toString <!> yield EnvsFileName
pModule :: CParser Char CpmAction a
pModule = spstrtok "module" &> pNotSpace <&> \mn -> pModuleAction <@ Module (toString mn)
pModule = spstrtok "module" &> pNotSpace <&> \mn -> (pModuleAction <!> yield ModuleHelp) <@ Module (toString mn)
where pModuleAction = spstrtok "create" <@ const CreateModule
<!> yield ModuleHelp
Start :: *World -> *World
Start world
......@@ -89,10 +87,10 @@ startParse args = case filter (\(xs, _) -> xs == []) (begin pCpm args) of
doCpmAction :: *World String String .CpmAction -> .World
doCpmAction world cleanhome pwd (Project pn pa) = doProjectAction world cleanhome pwd pn pa
doCpmAction world cleanhome pwd (Module mn ma) = doModuleAction world cleanhome mn ma
doCpmAction world _ _ _ =
doCpmAction world _ _ _ =
help "cpm <target>" [ "Where <target> is one of the following:"
, " project : project actions"
, " module : module action"
, " project <filename.prj> : project actions"
, " module : module actions"
, ""
, "Execute `cpm <target> help` to get help for specific actions."] world
......@@ -141,7 +139,7 @@ doProjectAction world cleanhome pwd pn (BuildProject force ideenvs)
= gst_world
doProjectAction world cleanhome _ pn (ProjectPath pa) = doProjectPathAction world cleanhome pn pa
doProjectAction world _ _ _ _ =
doProjectAction world _ _ _ _ =
help "cpm project <projectname.prj> <action>" [ "Where <action> is one of the following"
, " create : create a new project"
, " show : show project information"
......
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