From db3e864ae66da7f7d1034ae95967605144d5ec47 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 27 Jun 2021 20:09:48 -0400 Subject: Made obtaining env variables more granular + partial Lua support. --- stdlib/source/program/aedifex/command/clean.lux | 39 ++++++++++++------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'stdlib/source/program/aedifex/command/clean.lux') 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))) -- cgit v1.2.3