(.module: [library [lux {"-" [Name]} [program {"+" [program:]}] ["." debug] [abstract [monad {"+" [do]}]] [control [pipe {"+" [do>]}] ["." io {"+" [IO]}] ["." try {"+" [Try]} ("#\." functor)] ["." exception {"+" [exception:]}] [parser [environment {"+" [Environment]}]] [concurrency ["." async {"+" [Async]} ("#\." monad)]]] [data [binary {"+" [Binary]}] ["." text ["%" format {"+" [format]}] [encoding ["." utf8]]] [format ["." xml]] [collection ["." set] ["." dictionary {"+" [Dictionary]}] ["." list ("#\." functor)]]] [tool [compiler [language [lux ["." syntax]]]]] [world ["." shell {"+" [Exit Shell]}] ["." console {"+" [Console]}] ["." program {"+" [Program]}] ["." file {"+" [Path]} ["." watch]] [net ["." http "_" ["#" client]]]]]] ["." / "_" ["#" profile] ["#." action {"+" [Action]}] ["#." project {"+" [Project]}] ["#." input] ["#." parser] ["#." pom] ["#." cli] ["#." dependency "_" ["#" resolution {"+" [Resolution]}]] ["#." repository {"+" [Repository]} ["#/." remote {"+" [Address]}] ["#/." local]] ["#." command {"+" [Command]} ["#/." version] ["#/." clean] ["#/." pom] ["#/." install] ["#/." deps] ["#/." build] ["#/." test] ["#/." auto] ["#/." deploy]]]) (def: repositories (-> /.Profile (List (Repository Async))) (|>> (value@ #/.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 (value@ #/.identity profile) (#.Some artifact) (case (dictionary.value repository (value@ #/.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 (value@ #/.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))))))) ))))))