Commit 412ff028 authored by Mart Lubbers's avatar Mart Lubbers

implement environment rename .. for cpm

parent 60a8b3a8
Pipeline #21003 passed with stage
in 57 seconds
......@@ -245,23 +245,13 @@ doProjectAction _ _ _ _ world =
*/
doEnvironmentAction :: String String EnvironmentAction *World -> *World
doEnvironmentAction cleanhome pwd ListEnvironments world
# (envs, world) = readIDEEnvs cleanhome EnvsFileName world
= showLines [t.target_name\\t<-envs] world
= withEnvironments cleanhome (\ts w->(Nothing, showLines [t.target_name\\t<-ts] w)) world
doEnvironmentAction cleanhome pwd (ImportEnvironment ef) world
= error "Not implemented" world
doEnvironmentAction cleanhome pwd (RemoveEnvironment en) world
# (envs, world) = readIDEEnvs cleanhome EnvsFileName world
= case span (\s->s.target_name <> en) envs of
(_, []) = error ("Environment " +++ en +++ " not found") world
(e, [_:es])
# (ok, world) = writeIDEEnvs cleanhome EnvsFileName [t\\t<-envs | t.target_name <> en] world
| not ok = error ("Error writing environmint") world
= world
= withEnvironment cleanhome en (\_ w->(Just [], w)) world
doEnvironmentAction cleanhome pwd (ShowEnvironment en) world
# (envs, world) = readIDEEnvs cleanhome EnvsFileName world
# match = filter (\s->s.target_name == en) envs
| isEmpty match = error ("Environment " +++ en +++ " not found") world
= showLines (printEnvironment (hd match)) world
= withEnvironment cleanhome en (\e w->(Nothing, showLines (printEnvironment e) w)) world
where
printEnvironment e =
[ "Name: " +++ e.target_name
......@@ -289,7 +279,8 @@ where
]
doEnvironmentAction cleanhome pwd (ExportEnvironment en) world = error ("Not implemented") world
doEnvironmentAction cleanhome pwd (CreateEnvironment en) world = error ("Not implemented") world
doEnvironmentAction cleanhome pwd (RenameEnvironment en en`) world = error ("Not implemented") world
doEnvironmentAction cleanhome pwd (RenameEnvironment en en`) world
= withEnvironment cleanhome en (\t w->(Just [{t & target_name=en`}], w)) world
doEnvironmentAction cleanhome pwd (SetEnvironmentCompiler en cp) world = error ("Not implemented") world
doEnvironmentAction cleanhome pwd (SetEnvironmentCodeGen en cp) world = error ("Not implemented") world
doEnvironmentAction _ _ _ world =
......@@ -306,6 +297,23 @@ doEnvironmentAction _ _ _ world =
, " setcodegen <envname> <codegenname> : set codegen for <envname> to <codegenname>"
] world
withEnvironments :: String ([Target] *World -> (Maybe [Target], *World)) *World -> *World
withEnvironments cleanhome envf world
# (envs, world) = uncurry envf (readIDEEnvs cleanhome EnvsFileName world)
| isNothing envs = world
# (ok, world) = writeIDEEnvs cleanhome EnvsFileName (fromJust envs) world
| not ok = error ("Error writing environment") world
= world
withEnvironment :: String String (Target *World -> (Maybe [Target], *World)) -> (*World -> *World)
withEnvironment cleanhome envname envf
= withEnvironments cleanhome \ts world->
case span (\s->s.target_name <> envname) ts of
(_, []) = (Nothing, error ("Environment " +++ envname +++ " not found") world)
(e, [t:es]) = case envf t world of
(Nothing, world) = (Nothing, world)
(Just ts, world) = (Just (flatten [e, ts, es]), world)
/**
* Modify a project
*/
......
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