Commit b2cfe0dd authored by Jurrien Stutterheim's avatar Jurrien Stutterheim

Add "cpm Foo.prj" syntax for quick project building

parent 291ce7c6
......@@ -33,10 +33,13 @@ doCpmAction cleanhome pwd (Environment ea) world = doEnvironmentAction cleanh
doCpmAction _ _ _ world =
help "cpm <target>"
[ "Where <target> is one of the following:"
, " project <projectname> : project actions"
, " module <modulename> : module actions"
//, " environment : environment actions"
, " make : build all projects in the current directory"
, " <projectname> [--force] [--envs=filename] : build project <projectname>."
, " Optionally force build (default: 'false')"
, " Optionally specify the environments file (default: 'IDEEnvs')"
, " project <projectname> : project actions"
, " module <modulename> : module actions"
//, " environment : environment actions"
, " make : build all projects in the current directory"
, ""
, "Execute `cpm <target> help` to get help for specific actions."] world
......
......@@ -34,7 +34,8 @@ pNotSpace = ds (<+> (satisfy (not o space)))
*/
pCpm :: Parser Char a CpmAction
pCpm = //mkP ((\_ f -> Project "foo" (BuildProject f "foo")) <$> mkG (spstrtok "build") <||> mkG pForce)
pMake <|> pProject <|> pModule <!> (yield CpmHelp)
pMake <|> pProject <|> pModule <|> pQuickBuild <|> (yield CpmHelp)
where pQuickBuild = pNotSpace <&> \pn -> pBuildOpts <@ Project (toString pn)
/**
* Parse the make command
......@@ -54,15 +55,23 @@ spstrtok = ds o tokenH o fromString
*/
pProject :: Parser Char a CpmAction
pProject = spstrtok "project" &> (pProjectWithName <!> yield (Project "" ProjectHelp))
where pProjectWithName = mkP (Project o toString <$> mkG pNotSpace <||> mkG pProjectAction) //<&> \pn -> pProjectAction <@ Project (toString pn)
//where pProjectWithName = mkP (Project o toString <$> mkG pNotSpace <||> mkG pProjectAction) //<&> \pn -> pProjectAction <@ Project (toString pn)
where pProjectWithName = pNotSpace <&> \pn -> pProjectAction <@ Project (toString pn)
pProjectAction = (spstrtok "create" <@ const CreateProject)
<|> (spstrtok "show" <@ const ShowProject)
<|> mkP ((\_ -> BuildProject) <$> mkG (spstrtok "build") <||> mkG pForce <||> mkG pIDEEnvs) // (spstrtok "build" &> pForce <&> \f -> pIDEEnvs <@ BuildProject f)
//<|> mkP ((\_ -> BuildProject) <$> mkG (spstrtok "build") <||> mkG pForce <||> mkG pIDEEnvs) // (spstrtok "build" &> pForce <&> \f -> pIDEEnvs <@ BuildProject f)
<|> (spstrtok "build" &> pBuildOpts)
<|> (spstrtok "path" &> pPathAction)
<|> (spstrtok "root" &> pNotSpace <@ SetRelativeRoot o toString)
<|> (spstrtok "target" &> identifier <@ SetTarget o toString)
<|> (spstrtok "exec" &> identifier <@ SetExec o toString)
<!> (pHelp ProjectHelp)
<!> (pHelpYield ProjectHelp)
/**
* Parse options for the build command
*/
pBuildOpts :: Parser Char a ProjectAction
pBuildOpts = pForce <&> \f -> pIDEEnvs <@ BuildProject f
/**
* Parser for the environment commands
......@@ -78,7 +87,7 @@ pEnvironment = spstrtok "environment" &> pEnvironmentAction <@ Environment
<|> (spstrtok "rename" &> identifier <&> \en -> identifier <@ RenameEnvironment (toString en) o toString)
<|> (spstrtok "setcompiler" &> identifier <&> \en -> identifier <@ SetEnvironmentCompiler (toString en) o toString)
<|> (spstrtok "setcodegen" &> identifier <&> \en -> identifier <@ SetEnvironmentCodeGen (toString en) o toString)
<!> (pHelp EnvironmentHelp)
<!> (pHelpYield EnvironmentHelp)
/**
* Parser for all path-related actions
......@@ -89,7 +98,7 @@ pPathAction = pPathAction <@ ProjectPath
<|> (spstrtok "remove" &> ds number <@ RemovePathAction)
<|> (spstrtok "list" <@ const ListPathsAction)
<|> (spstrtok "move" &> pPathDirection)
<!> (pHelp PathHelp)
<!> (pHelpYield PathHelp)
pPathDirection = ds number <&> \i -> pConstCtr dirOpts <@ MovePathAction i
dirOpts = [ ("up", MovePathUp), ("down", MovePathDown)
, ("top", MovePathTop), ("bottom", MovePathBottom)]
......@@ -120,7 +129,7 @@ pModule :: Parser Char a CpmAction
pModule = spstrtok "module" &> (pModuleWithName <!> yield (Module "" ModuleHelp))
where pModuleWithName = pNotSpace <&> \mn -> pModuleAction <@ Module (toString mn)
pModuleAction = (spstrtok "create" &> pModuleType <@ CreateModule)
<!> (pHelp ModuleHelp)
<!> (pHelpYield ModuleHelp)
pModuleType = (spstrtok "application" <@ const ApplicationModule)
<!> (yield LibraryModule)
......@@ -128,7 +137,10 @@ pModule = spstrtok "module" &> (pModuleWithName <!> yield (Module "" ModuleHelp)
* Parser for the help command
*/
pHelp :: c -> Parser Char a c
pHelp c = (spstrtok "help" <@ const c) <|> (yield c)
pHelp c = spstrtok "help" <@ const c
pHelpYield :: c -> Parser Char a c
pHelpYield c = (spstrtok "help" <@ const c) <|> (yield c)
/**
* Parse the a list of characters to get the action to be executed. If parsing
......
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