Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clean-ide
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
clean-and-itasks
clean-ide
Commits
c20eebd2
Commit
c20eebd2
authored
Mar 11, 2013
by
Jurrien Stutterheim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor doProjectPathAction
parent
8d8db4f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
23 deletions
+17
-23
cpm/Cpm.icl
cpm/Cpm.icl
+17
-23
No files found.
cpm/Cpm.icl
View file @
c20eebd2
...
...
@@ -187,33 +187,18 @@ doProjectAction _ _ _ _ world =
,
" path : manage project paths"
]
world
doProjectPathAction
::
.
String
.
String
Project
.
PathAction
*
World
->
.
World
doProjectPathAction
cleanhome
pn
project
(
AddPathAction
path
)
world
#
(
ok
,
world
)
=
saveProject
cleanhome
prj
pn
world
|
not
ok
=
abort
"Failed to add path to project"
// TODO: Improve
=
showLines
[
"Path '"
+++
path
+++
"' successfully added to project"
]
world
where
prj
=
PR_SetPaths
False
paths
(
path
:!
paths
)
project
// TODO: Double check to see if PR_SetPaths is used correctly
paths
=
PR_GetPaths
project
doProjectPathAction
cleanhome
pn
project
(
AddPathAction
path
)
world
=
doModPaths
cleanhome
pn
project
(\
paths
->
path
:!
paths
)
world
doProjectPathAction
cleanhome
pn
project
(
RemovePathAction
i
)
world
#
(
ok
,
world
)
=
saveProject
cleanhome
prj
pn
world
|
not
ok
=
abort
"Failed to remove path from project"
// TODO: Improve
=
showLines
[
"Path "
+++
toString
i
+++
" successfully removed from project"
]
world
where
paths
=
PR_GetPaths
project
paths`
=
rmStrictListIdx
i
paths
prj
=
PR_SetPaths
False
paths
paths`
project
// TODO: Double check to see if PR_SetPaths is used correctly
doProjectPathAction
cleanhome
pn
project
(
RemovePathAction
i
)
world
=
doModPaths
cleanhome
pn
project
(
rmStrictListIdx
i
)
world
doProjectPathAction
_
_
project
ListPathsAction
world
=
showLines
[
"Paths for project:"
:
paths
]
world
where
paths
=
map
f
(
zip2
[
0
..]
(
StrictListToList
(
PR_GetPaths
project
)))
f
(
n
,
p
)
=
" ["
+++
toString
n
+++
"] "
+++
p
// TODO: Refactor and combine with removepath and addpath
doProjectPathAction
cleanhome
pn
project
(
MovePathAction
i
pdir
)
world
#
(
ok
,
world
)
=
saveProject
cleanhome
prj
pn
world
|
not
ok
=
abort
"Failed to move path"
// TODO: Improve
=
showLines
[
"Path "
+++
toString
i
+++
" successfully moved"
]
world
where
paths
=
PR_GetPaths
project
paths`
=
moveStrictListIdx
i
pdir
paths
prj
=
PR_SetPaths
False
paths
paths`
project
// TODO: Double check to see if PR_SetPaths is used correctly
doProjectPathAction
cleanhome
pn
project
(
MovePathAction
i
pdir
)
world
=
doModPaths
cleanhome
pn
project
(
moveStrictListIdx
i
pdir
)
world
doProjectPathAction
_
_
_
_
world
=
help
"cpm project <projectname> path <action>"
...
...
@@ -223,6 +208,15 @@ doProjectPathAction _ _ _ _ world =
,
" remove <i> : remove path <i> from the list of projects"
,
" move <i> <up|down> : move path <i> up or down one position"
]
world
doModPaths
::
String
String
Project
.([!
String
!]
->
[!
String
!])
*
World
->
.
World
doModPaths
cleanhome
pn
project
f
world
#
(
ok
,
world
)
=
saveProject
cleanhome
prj
pn
world
|
not
ok
=
abort
"Failed to modify project paths"
=
showLines
[
"Successfully modified project paths"
]
world
where
paths
=
PR_GetPaths
project
prj
=
PR_SetPaths
False
paths
(
f
paths
)
project
openProject
::
!
FilePath
!
FilePath
!*
World
->
(!
MaybeErrorString
Project
,!*
World
)
openProject
cleanhome
projectfile
world
#
((
prj
,
ok
,
err
),
world
)
=
accFiles
(
ReadProjectFile
projectfile
cleanhome
)
world
...
...
@@ -232,12 +226,12 @@ openProject cleanhome projectfile world
saveProject
::
!
FilePath
!
Project
!
FilePath
!*
World
->
(
Bool
,
!*
World
)
saveProject
cleanhome
prj
projectfile
world
=
accFiles
(
SaveProjectFile
projectfile
prj
cleanhome
)
world
rmStrictListIdx
::
!
Int
!(
List
String
)
->
List
String
rmStrictListIdx
::
Int
u
:[!.
a
!]
->
v
:[!.
a
!],
[
u
<=
v
]
rmStrictListIdx
0
(_
:!
t
)
=
t
rmStrictListIdx
n
(
h
:!
t
)
|
n
>
0
=
h
:!
(
rmStrictListIdx
(
n
-
1
)
t
)
rmStrictListIdx
n
_
=
abort
(
"Index "
+++
toString
n
+++
" out of bounds"
)
moveStrictListIdx
::
!
Int
!
PathDirection
!(
List
String
)
->
List
String
moveStrictListIdx
::
.
Int
.
PathDirection
.[!
a
!]
->
.[!
a
!]
moveStrictListIdx
i
dir
xs
|
i
<
0
||
i
>
(
LLength
xs
-
1
)
=
abort
(
"Index "
+++
toString
i
+++
" out of bounds"
)
|
otherwise
=
ListToStrictList
(
msl
dir
(
splitAt
i
(
StrictListToList
xs
)))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment