aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/command/clean.lux
diff options
context:
space:
mode:
authorEduardo Julian2021-06-27 20:09:48 -0400
committerEduardo Julian2021-06-27 20:09:48 -0400
commitdb3e864ae66da7f7d1034ae95967605144d5ec47 (patch)
tree29c51002455a2c8f7d4aa25ab13c688cfa8d60e3 /stdlib/source/program/aedifex/command/clean.lux
parentb80f79ae6b2e240949ebd709a253e21f7caf7ed3 (diff)
Made obtaining env variables more granular + partial Lua support.
Diffstat (limited to 'stdlib/source/program/aedifex/command/clean.lux')
-rw-r--r--stdlib/source/program/aedifex/command/clean.lux39
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)))