(.module: [lux (#- Name) [abstract [monad (#+ do)]] [control [pipe (#+ do>)] ["." io (#+ IO)] ["." try (#+ Try)] ["." exception (#+ exception:)] [parser ["." cli (#+ program:)] ["" code]] [security ["!" capability]] [concurrency ["." promise (#+ Promise) ("#@." monad)]]] [data [binary (#+ Binary)] ["." text ["%" format (#+ format)] ["." encoding]] [format ["." xml]] [collection ["." set] ["." dictionary (#+ Dictionary)] ["." list ("#\." functor)]]] [tool [compiler [language [lux ["." syntax]]]]] [world ["." file (#+ Path)]]] ["." / #_ ["#" profile] ["#." action (#+ Action)] ["#." project (#+ Project)] ["#." input] ["#." parser] ["#." pom] ["#." cli] ["#." cache] ["#." repository (#+ Address Repository)] ["#." dependency #_ ["#" resolution]] ["#." command (#+ Command) ["#/." clean] ["#/." pom] ["#/." install] ["#/." deps] ["#/." build] ["#/." test] ["#/." auto] ["#/." deploy]]]) (def: repositories (-> /.Profile (List (Repository Promise))) (|>> (get@ #/.repositories) set.to-list (list\map (|>> /repository.remote /repository.async)))) (def: (with-dependencies command profile) (All [a] (-> (Command a) (Command a))) (do /action.monad [_ (/command/deps.do! (file.async file.default) (..repositories profile) profile)] (command profile))) (exception: (cannot-find-repository {repository Text} {options (Dictionary Text Address)}) (exception.report ["Repository" (%.text repository)] ["Options" (exception.enumerate (function (_ [name repo]) (format (%.text name) " := " (%.text repo))) (dictionary.entries options))])) (program: [{[profile operation] /cli.command}] (do {! io.monad} [?profile (/input.read io.monad file.default profile)] (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 [])) #/cli.Install (exec (/command/install.do! (file.async file.default) profile) (wrap [])) (#/cli.Deploy repository identity) (exec (case [(get@ #/.identity profile) (dictionary.get repository (get@ #/.deploy-repositories profile))] [(#.Some artifact) (#.Some repository)] (/command/deploy.do! (/repository.async (/repository.remote repository)) (file.async file.default) identity artifact profile) [#.None _] (promise@wrap (exception.throw /.no-identity [])) [_ #.None] (promise@wrap (exception.throw ..cannot-find-repository [repository (get@ #/.deploy-repositories profile)]))) (wrap [])) #/cli.Dependencies (exec (/command/deps.do! (file.async file.default) (..repositories profile) profile) (wrap [])) (#/cli.Compilation compilation) (case compilation #/cli.Build (exec (..with-dependencies /command/build.do! profile) (wrap [])) #/cli.Test (exec (..with-dependencies /command/test.do! profile) (wrap []))) (#/cli.Auto auto) (exec (case auto #/cli.Build (..with-dependencies (/command/auto.do! /command/build.do!) profile) #/cli.Test (..with-dependencies (/command/auto.do! /command/test.do!) profile)) (wrap []))) (#try.Failure error) (wrap (log! error)))))