diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/program/aedifex/command/clean.lux | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/stdlib/source/program/aedifex/command/clean.lux b/stdlib/source/program/aedifex/command/clean.lux index 900de2cc4..ecb71b59d 100644 --- a/stdlib/source/program/aedifex/command/clean.lux +++ b/stdlib/source/program/aedifex/command/clean.lux @@ -8,6 +8,9 @@ ["!" capability]] [concurrency ["." promise (#+ Promise)]]] + [data + [text + ["%" format (#+ format)]]] [world ["." file (#+ Path File Directory)] ["." console (#+ Console)]]] @@ -26,27 +29,21 @@ nodes)] (wrap []))) -(def: #export success - "Success") - -(def: #export failure - "Failure: No 'target' defined for clean-up.") +(def: #export (success path) + (-> ///.Target Text) + (format "Successfully cleaned target directory: " path)) (def: #export (do! console fs profile) (-> (Console Promise) (file.System Promise) (Command Any)) - (case (get@ #///.target profile) - (#.Some target) - (do {! ///action.monad} - [target (: (Promise (Try (Directory Promise))) - (!.use (\ fs directory) target)) - _ (loop [root target] - (do ! - [_ (..clean_files! root) - subs (: (Promise (Try (List (Directory Promise)))) - (!.use (\ root directories) [])) - _ (monad.map ! recur subs)] - (!.use (\ root discard) [])))] - (console.write_line ..success console)) - - #.None - (console.write_line ..failure console))) + (do {! ///action.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))) |