aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2022-03-14 22:54:32 -0400
committerEduardo Julian2022-03-14 22:54:32 -0400
commit4ef1ac1dfe0edd1a11bb7f1fd13c8b6cb8f1bab4 (patch)
tree715a0d1c18460eda24e49aea837f59d120169318
parent41495e32d3f5f88b5f189f48dd4fdbfa883c6ac0 (diff)
Using a fake console in Aedifex if the system console is unavailable.
Diffstat (limited to '')
-rw-r--r--.github/workflows/test.yml46
-rw-r--r--stdlib/source/program/aedifex.lux202
2 files changed, 134 insertions, 114 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 51b51ece0..9f7c37116 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -6,7 +6,7 @@ jobs:
steps:
- uses: actions/checkout@v2
# Setup Aedifex
- - run: wget https://github.com/LuxLang/lux/releases/download/0.6.5/aedifex.jar
+ - run: wget https://github.com/LuxLang/lux/releases/download/0.6.5/aedifex_do_not_touch_0.jar && mv aedifex_do_not_touch_0.jar aedifex.jar
- run: mv ./shell/lux.sh ./lux.sh
# Test on the JVM
# https://github.com/actions/setup-java
@@ -15,26 +15,26 @@ jobs:
distribution: 'temurin'
java-version: '17'
- run: cd ./stdlib/ && ../lux.sh clean && ../lux.sh with jvm with bibliotheca test && cd ..
- # Test on Node
- - uses: actions/setup-node@v2
- with:
- node-version: '14'
- - run: cd ./stdlib/ && ../lux.sh clean && ../lux.sh with js with bibliotheca test && cd ..
- # Test on Lua
- # https://github.com/marketplace/actions/setup-lua-luajit
- - uses: xpol/setup-lua@v1
- - run: cd ./stdlib/ && ../lux.sh clean && ../lux.sh with lua with bibliotheca test && cd ..
- # Test on Python
- # https://github.com/actions/setup-python
- - uses: actions/setup-python@v2
- with:
- python-version: '3.9'
- architecture: 'x64'
- - run: cd ./stdlib/ && ../lux.sh clean && ../lux.sh with python with bibliotheca test && cd ..
- # Test on Ruby
- # https://github.com/actions/setup-ruby
- - uses: actions/setup-ruby@v1
- with:
- ruby-version: '2.6'
- - run: cd ./stdlib/ && ../lux.sh clean && ../lux.sh with ruby with bibliotheca test && cd ..
+# # Test on Node
+# - uses: actions/setup-node@v2
+# with:
+# node-version: '14'
+# - run: cd ./stdlib/ && ../lux.sh clean && ../lux.sh with js with bibliotheca test && cd ..
+# # Test on Lua
+# # https://github.com/marketplace/actions/setup-lua-luajit
+# - uses: xpol/setup-lua@v0.3
+# - run: cd ./stdlib/ && ../lux.sh clean && ../lux.sh with lua with bibliotheca test && cd ..
+# # Test on Python
+# # https://github.com/actions/setup-python
+# - uses: actions/setup-python@v2
+# with:
+# python-version: '3.9'
+# architecture: 'x64'
+# - run: cd ./stdlib/ && ../lux.sh clean && ../lux.sh with python with bibliotheca test && cd ..
+# # Test on Ruby
+# # https://github.com/actions/setup-ruby
+# - uses: actions/setup-ruby@v1
+# with:
+# ruby-version: '2.6'
+# - run: cd ./stdlib/ && ../lux.sh clean && ../lux.sh with ruby with bibliotheca test && cd ..
diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux
index 4145bb9c5..a92340ce3 100644
--- a/stdlib/source/program/aedifex.lux
+++ b/stdlib/source/program/aedifex.lux
@@ -7,6 +7,7 @@
[monad {"+" do}]]
[control
["[0]" io {"+" IO}]
+ ["[0]" maybe]
["[0]" try {"+" Try} ("[1]#[0]" functor)]
["[0]" exception {"+" exception:}]
[parser
@@ -111,100 +112,119 @@
(def: (command action)
(All (_ a) (-> (Async (Try a)) (IO Any)))
- (exec (do async.monad
- [outcome action]
- (async.future
- (case outcome
- {try.#Success _}
- ..succeed!
-
- {try.#Failure error}
- (..fail! error))))
+ (exec
+ (do async.monad
+ [outcome action]
+ (async.future
+ (case outcome
+ {try.#Success _}
+ ..succeed!
+
+ {try.#Failure error}
+ (..fail! error))))
(# io.monad in [])))
+(exception: .public invalid_operation)
+
+(`` (implementation: write_only
+ (Console IO)
+
+ (~~ (template [<name>]
+ [(def: (<name> _)
+ (io.io (exception.except ..invalid_operation [])))]
+
+ [read]
+ [read_line]
+ [close]
+ ))
+
+ (def: (write it)
+ (<| io.io
+ {try.#Success}
+ debug.log!
+ (if (text.ends_with? text.\n it)
+ (maybe.trusted (text.clip 0 (-- (text.size it)) it))
+ it)))))
+
(program: [[profiles operation] /cli.command]
(do [! io.monad]
- [?console console.default]
- (case (try#each console.async ?console)
- {try.#Failure error}
- (..fail! error)
-
- {try.#Success console}
- (case operation
- {/cli.#Version}
- (..command
- (/command/version.do! console (# /.monoid identity)))
-
- _
- (do !
- [?profile (/input.read io.monad file.default profiles)]
- (case ?profile
- {try.#Failure error}
- (..fail! error)
-
- {try.#Success profile}
- (let [program (program.async program.default)]
- (case operation
- {/cli.#Version}
- (in [])
-
- {/cli.#Clean}
- (..command
- (/command/clean.do! console (file.async file.default) profile))
-
- {/cli.#POM}
- (..command
- (/command/pom.do! console (file.async file.default) profile))
-
- {/cli.#Install}
- (..command
- (let [fs (file.async file.default)]
- (/command/install.do! console fs (/repository/local.repository program fs) profile)))
-
- {/cli.#Deploy repository identity}
- (..command
- (case (the /.#identity profile)
- {.#Some artifact}
- (case (dictionary.value repository (the /.#deploy_repositories profile))
- {.#Some repository}
- (/command/deploy.do! console
- (/repository.async (/repository/remote.repository http.default {.#Some identity} repository))
- (file.async file.default)
- artifact
- profile)
-
- {.#None}
- (async#in (exception.except ..cannot_find_repository [repository (the /.#deploy_repositories profile)])))
+ [console (# ! each (|>> (try.else ..write_only) console.async)
+ console.default)]
+ (case operation
+ {/cli.#Version}
+ (..command
+ (/command/version.do! console (# /.monoid identity)))
+
+ _
+ (do !
+ [?profile (/input.read io.monad file.default profiles)]
+ (case ?profile
+ {try.#Failure error}
+ (..fail! error)
+
+ {try.#Success profile}
+ (let [program (program.async program.default)]
+ (case operation
+ {/cli.#Version}
+ (in [])
+
+ {/cli.#Clean}
+ (..command
+ (/command/clean.do! console (file.async file.default) profile))
+
+ {/cli.#POM}
+ (..command
+ (/command/pom.do! console (file.async file.default) profile))
+
+ {/cli.#Install}
+ (..command
+ (let [fs (file.async file.default)]
+ (/command/install.do! console fs (/repository/local.repository program fs) profile)))
+
+ {/cli.#Deploy repository identity}
+ (..command
+ (case (the /.#identity profile)
+ {.#Some artifact}
+ (case (dictionary.value repository (the /.#deploy_repositories profile))
+ {.#Some repository}
+ (/command/deploy.do! console
+ (/repository.async (/repository/remote.repository http.default {.#Some identity} repository))
+ (file.async file.default)
+ artifact
+ profile)
{.#None}
- (async#in (exception.except /.no_identity []))))
-
- {/cli.#Dependencies}
- (..command
- (/command/deps.do! console
- (/repository/local.repository program (file.async file.default))
- (..repositories profile)
- (|>> (/repository/remote.repository http.default {.#None})
- /repository.async)
- profile))
-
- {/cli.#Compilation compilation}
- (case compilation
- {/cli.#Build} (..command
- (..with_dependencies program console /command/build.do! profile))
- {/cli.#Test} (..command
- (..with_dependencies program console /command/test.do! profile)))
-
- {/cli.#Auto auto}
- (do !
- [?watcher watch.default]
- (case ?watcher
- {try.#Failure error}
- (..fail! error)
-
- {try.#Success watcher}
- (..command
- (case auto
- {/cli.#Build} (..with_dependencies program console (/command/auto.do! /command/auto.delay watcher /command/build.do!) profile)
- {/cli.#Test} (..with_dependencies program console (/command/auto.do! /command/auto.delay watcher /command/test.do!) profile)))))))
- ))))))
+ (async#in (exception.except ..cannot_find_repository [repository (the /.#deploy_repositories profile)])))
+
+ {.#None}
+ (async#in (exception.except /.no_identity []))))
+
+ {/cli.#Dependencies}
+ (..command
+ (/command/deps.do! console
+ (/repository/local.repository program (file.async file.default))
+ (..repositories profile)
+ (|>> (/repository/remote.repository http.default {.#None})
+ /repository.async)
+ profile))
+
+ {/cli.#Compilation compilation}
+ (case compilation
+ {/cli.#Build} (..command
+ (..with_dependencies program console /command/build.do! profile))
+ {/cli.#Test} (..command
+ (..with_dependencies program console /command/test.do! profile)))
+
+ {/cli.#Auto auto}
+ (do !
+ [?watcher watch.default]
+ (case ?watcher
+ {try.#Failure error}
+ (..fail! error)
+
+ {try.#Success watcher}
+ (..command
+ (case auto
+ {/cli.#Build} (..with_dependencies program console (/command/auto.do! /command/auto.delay watcher /command/build.do!) profile)
+ {/cli.#Test} (..with_dependencies program console (/command/auto.do! /command/auto.delay watcher /command/test.do!) profile)))))))
+ )))))