(.module: [library [lux #* [abstract ["." monad (#+ do)]] [control [try (#+ Try)] [concurrency ["." async (#+ Async)]]] [data [text ["%" format (#+ format)]]] [world ["." file (#+ Path)] ["." console (#+ Console)]]]] ["." /// #_ [command (#+ Command)] ["#" profile] ["#." action (#+ Action)]]) (def: (clean_files! fs root) (-> (file.System Async) Path (Async (Try Any))) (let [! ///action.monad] (|> root (\ fs directory_files) (\ ! each (monad.each ! (\ fs delete))) (\ ! conjoint)))) (def: .public success (-> ///.Target Text) (|>> (format "Successfully cleaned target directory: "))) (def: .public (do! console fs profile) (-> (Console Async) (file.System Async) (Command Any)) (do {! async.monad} [.let [target (value@ #///.target profile)] ? (\ fs directory? target) _ (let [! ///action.monad] (if ? (loop [root target] (do ! [_ (..clean_files! fs root) _ (|> root (\ fs sub_directories) (\ ! each (monad.each ! recur)) (\ ! conjoint))] (\ fs delete root))) (\ ! in [])))] (console.write_line (..success target) console)))