Commit ebb0e9c8 authored by Jurrien Stutterheim's avatar Jurrien Stutterheim
Browse files

Improve cpm parser

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