aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/command/clean.lux
diff options
context:
space:
mode:
authorEduardo Julian2021-06-30 23:24:55 -0400
committerEduardo Julian2021-06-30 23:24:55 -0400
commit744ee69630de59ca3ba660b0aab6361cd17ce1b4 (patch)
tree329c11b8c3522c319c99ebd4d7c51ee0e7464bae /stdlib/source/program/aedifex/command/clean.lux
parent6633cd42f2892ea71530ddeeb93a7e7c0b59faa3 (diff)
"signature:" -> "interface:" & "structure:" -> "implementation:"
"signature" & "structure" feel like very ML-specific terminology and might not be easy on programmers unfamiliar with it.
Diffstat (limited to 'stdlib/source/program/aedifex/command/clean.lux')
-rw-r--r--stdlib/source/program/aedifex/command/clean.lux29
1 files changed, 19 insertions, 10 deletions
diff --git a/stdlib/source/program/aedifex/command/clean.lux b/stdlib/source/program/aedifex/command/clean.lux
index ecb71b59d..b966fe85e 100644
--- a/stdlib/source/program/aedifex/command/clean.lux
+++ b/stdlib/source/program/aedifex/command/clean.lux
@@ -4,6 +4,7 @@
["." monad (#+ do)]]
[control
["." try (#+ Try)]
+ ["." exception]
[security
["!" capability]]
[concurrency
@@ -35,15 +36,23 @@
(def: #export (do! console fs profile)
(-> (Console Promise) (file.System Promise) (Command Any))
- (do {! ///action.monad}
+ (do promise.monad
[#let [target (get@ #///.target profile)]
root (: (Promise (Try (Directory Promise)))
- (!.use (\ fs directory) target))
- _ (loop [root root]
- (do !
- [_ (..clean_files! root)
- subs (: (Promise (Try (List (Directory Promise))))
- (!.use (\ root directories) []))
- _ (monad.map ! recur subs)]
- (!.use (\ root discard) [])))]
- (console.write_line (..success target) console)))
+ (!.use (\ fs directory) target))]
+ (case root
+ (#try.Success root)
+ (do {! ///action.monad}
+ [_ (loop [root root]
+ (do !
+ [_ (..clean_files! root)
+ subs (: (Promise (Try (List (Directory Promise))))
+ (!.use (\ root directories) []))
+ _ (monad.map ! recur subs)]
+ (!.use (\ root discard) [])))]
+ (console.write_line (..success target) console))
+
+ (#try.Failure error)
+ (if (exception.match? file.cannot_find_directory error)
+ (console.write_line (..success target) console)
+ (\ promise.monad wrap (#try.Failure error))))))