(.using [library [lux "*" [program {"+" program:}] ["[0]" debug] [abstract [monad {"+" do}]] [control [pipe {"+" do>}] ["[0]" io {"+" IO}] ["[0]" try {"+" Try} ("[1]#[0]" functor)] ["[0]" exception {"+" exception:}] [parser [environment {"+" Environment}]] [concurrency ["[0]" async {"+" Async} ("[1]#[0]" monad)]]] [data [binary {"+" Binary}] ["[0]" text ["%" format {"+" format}] [encoding ["[0]" utf8]]] [format ["[0]" xml]] [collection ["[0]" set] ["[0]" dictionary {"+" Dictionary}] ["[0]" list ("[1]#[0]" functor)]]] [tool [compiler [language [lux ["[0]" syntax]]]]] [world ["[0]" shell {"+" Exit Shell}] ["[0]" console {"+" Console}] ["[0]" program {"+" Program}] ["[0]" file {"+" Path} ["[0]" watch]] [net ["[0]" http "_" ["[1]" client]]]]]] ["[0]" / "_" ["[1]" profile] ["[1][0]" action {"+" Action}] ["[1][0]" project {"+" Project}] ["[1][0]" input] ["[1][0]" pom] ["[1][0]" cli] ["[1][0]" dependency "_" ["[1]" resolution {"+" Resolution}]] ["[1][0]" repository {"+" Repository} ["[1]/[0]" remote {"+" Address}] ["[1]/[0]" local]] ["[1][0]" command {"+" Command} ["[1]/[0]" version] ["[1]/[0]" clean] ["[1]/[0]" pom] ["[1]/[0]" install] ["[1]/[0]" deps] ["[1]/[0]" build] ["[1]/[0]" test] ["[1]/[0]" auto] ["[1]/[0]" deploy]]]) (def: repositories (-> /.Profile (List (Repository Async))) (|>> (the /.#repositories) set.list (list#each (|>> (/repository/remote.repository http.default {.#None}) /repository.async)))) (def: (with_dependencies program console command profile) (All (_ a) (-> (Program Async) (Console Async) (-> (Console Async) (Program Async) (file.System Async) (Shell Async) Resolution (Command [Exit a])) (Command a))) (do /action.monad [resolution (/command/deps.do! console (/repository/local.repository program (file.async file.default)) (..repositories profile) (|>> (/repository/remote.repository http.default {.#None}) /repository.async) profile) [exit_code output] ((command console program (file.async file.default) (shell.async shell.default) resolution) profile) _ (case exit_code (^ (static shell.normal)) (in []) _ (do async.monad [_ (# program exit exit_code)] (in {try.#Failure ""})))] (in output))) (exception: (cannot_find_repository [repository Text options (Dictionary Text Address)]) (exception.report ["Repository" (%.text repository)] ["Options" (exception.listing (function (_ [name repo]) (format (%.text name) " := " (%.text repo))) (dictionary.entries options))])) (def: succeed! (IO Any) (# program.default exit shell.normal)) (def: (fail! error) (-> Text (IO Any)) (exec (debug.log! error) (# program.default exit shell.error))) (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)))) (# io.monad in []))) (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)]))) {.#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))))))) ))))))