diff --git a/build.clj b/build.clj index 7a942d3..d7c9f66 100644 --- a/build.clj +++ b/build.clj @@ -3,7 +3,7 @@ [deps-deploy.deps-deploy :as dd])) (def lib 'org.clojars.some/depo) -(def version "0.0.19") +(def version "0.0.20") (def jar-file (format "target/%s-%s.jar" (name lib) version)) (def class-dir "target/classes") (def url "https://github.com/somecho/depo") diff --git a/src/depo/core.clj b/src/depo/core.clj index 1e1f24c..af72da9 100644 --- a/src/depo/core.clj +++ b/src/depo/core.clj @@ -22,12 +22,16 @@ (defn update-cmd [{:keys [_arguments file]}] (let [args _arguments config-path (if file file (rw/get-config))] - (println args))) + (if (empty? args) + (do (mapv #(rw/update-dependency config-path %) + (rw/get-all-dependency-names config-path)) + (println "Done!")) + (mapv #(rw/update-dependency config-path %) args)))) (def CONFIGURATION {:command "depo" :description "Manage dependencies for Clojure projects easily" - :version "0.0.19" + :version "0.0.20" :opts [{:as "path to configuration file" :default nil :option "file" diff --git a/src/depo/readwrite.clj b/src/depo/readwrite.clj index f242496..5d9ef04 100644 --- a/src/depo/readwrite.clj +++ b/src/depo/readwrite.clj @@ -141,6 +141,30 @@ :wrap-coll? nil}}) (as-> new-conf (spit config-path new-conf))))) +(defmulti get-all-dependency-names + "Returns all the dependencies from the config" + (fn [config-path] config-path)) + +(defmethod get-all-dependency-names :default + [config-path] + (let [zloc (z/of-string (slurp config-path))] + (-> zloc + (z/get :deps) + (z/string) + (read-string) + (keys) + (as-> keys (map str keys))))) + +(defmethod get-all-dependency-names "project.clj" + [config-path] + (let [zloc (z/of-string (slurp config-path))] + (-> zloc + (z/find-value z/next :dependencies) + (z/next) + (z/string) + (read-string) + (as-> dep-vec (map #(str (first %)) dep-vec))))) + (defmulti update-dependency "Updates a dependency in a Clojure project" (fn [config-path dependency] config-path))