aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program
diff options
context:
space:
mode:
authorEduardo Julian2020-11-02 20:54:09 -0400
committerEduardo Julian2020-11-02 20:54:09 -0400
commitfd3152f29c8d8e9cc134423da18fb828ba20ebcc (patch)
tree5550c43f1eb07c9776314c0d908a8fb91a88881b /stdlib/source/program
parent03b1085924b225d34d3b11f1a442b0b5d926c417 (diff)
Added CoMonad for CoFree.
Diffstat (limited to '')
-rw-r--r--stdlib/source/program/aedifex.lux5
-rw-r--r--stdlib/source/program/aedifex/cli.lux4
-rw-r--r--stdlib/source/program/aedifex/command/clean.lux47
3 files changed, 56 insertions, 0 deletions
diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux
index a3712a19f..d4c9036f3 100644
--- a/stdlib/source/program/aedifex.lux
+++ b/stdlib/source/program/aedifex.lux
@@ -41,6 +41,7 @@
["#." dependency #_
["#" resolution]]
["#." command
+ ["#/." clean]
["#/." pom]
["#/." install]
["#/." build]
@@ -75,6 +76,10 @@
(case ?profile
(#try.Success profile)
(case operation
+ #/cli.Clean
+ (exec (/command/clean.do! (file.async file.default) profile)
+ (wrap []))
+
#/cli.POM
(exec (/command/pom.do! (file.async file.default) profile)
(wrap []))
diff --git a/stdlib/source/program/aedifex/cli.lux b/stdlib/source/program/aedifex/cli.lux
index 666e5a701..9d73f9181 100644
--- a/stdlib/source/program/aedifex/cli.lux
+++ b/stdlib/source/program/aedifex/cli.lux
@@ -32,6 +32,7 @@
(cli.this "test")))
(type: #export Command
+ #Clean
#POM
#Dependencies
#Install
@@ -42,6 +43,8 @@
(def: #export equivalence
(Equivalence Command)
($_ equivalence.sum
+ ## #Clean
+ ..any-equivalence
## #POM
..any-equivalence
## #Dependencies
@@ -61,6 +64,7 @@
(def: command'
(Parser Command)
($_ <>.or
+ (cli.this "clean")
(cli.this "pom")
(cli.this "deps")
(cli.this "install")
diff --git a/stdlib/source/program/aedifex/command/clean.lux b/stdlib/source/program/aedifex/command/clean.lux
new file mode 100644
index 000000000..f4f5e1f9e
--- /dev/null
+++ b/stdlib/source/program/aedifex/command/clean.lux
@@ -0,0 +1,47 @@
+(.module:
+ [lux #*
+ [abstract
+ ["." monad (#+ do)]]
+ [control
+ ["." try (#+ Try)]
+ [security
+ ["!" capability]]
+ [concurrency
+ ["." promise (#+ Promise)]]]
+ [world
+ ["." file (#+ Path File Directory)]]]
+ ["." /// #_
+ [command (#+ Command)]
+ ["#" profile]
+ ["#." action (#+ Action)]])
+
+(def: (clean-files! root)
+ (-> (Directory Promise) (Promise (Try Any)))
+ (do {! ///action.monad}
+ [nodes (: (Promise (Try (List (File Promise))))
+ (!.use (:: root files) []))
+ _ (monad.map ! (function (_ node)
+ (!.use (:: node delete) []))
+ nodes)]
+ (wrap [])))
+
+(def: #export (do! fs profile)
+ (-> (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) [])))]
+ (exec (log! "No 'target' defined for clean-up.")
+ (wrap [])))
+
+ #.None
+ (exec (log! "No 'target' defined for clean-up.")
+ (:: ///action.monad wrap []))))