Skip to content

Commit

Permalink
feat: Add --changes-in-table option
Browse files Browse the repository at this point in the history
cf. #240
  • Loading branch information
liquidz committed Dec 1, 2023
1 parent 020a847 commit 7e9af77
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/antq/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
[nil "--check-clojure-tools"]
[nil "--no-diff"] ; deprecated (for backward compatibility)
[nil "--no-changes"]
[nil "--changes-in-table"]
[nil "--transitive"]])

(defn skip-artifacts?
Expand Down
32 changes: 18 additions & 14 deletions src/antq/report/table.clj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
(->> columns
(map-indexed (fn [i column]
(format (str "%-" (nth max-lengths i) "s")
(get dep column))))
(or (get dep column)
""))))
(str/join " | ")
(format "| %s |")))

Expand All @@ -43,8 +44,10 @@
s)))

(defn- print-table
[deps]
(let [columns [:file :name :current :latest]
[options deps]
(let [columns (cond-> [:file :name :current :latest]
(:changes-in-table options)
(conj :changes-url))
max-lengths (map #(calc-max-length % deps) columns)]
(println (generate-row (->> columns
(map #(vector % (str %)))
Expand All @@ -58,7 +61,7 @@
(println (generate-row dep columns max-lengths)))))

(defmethod report/reporter "table"
[deps _options]
[deps options]
;; Show table
(if (empty? deps)
(println "All dependencies are up-to-date.")
Expand All @@ -76,18 +79,19 @@
(set/rename-keys % {:version :current
latest-key :latest})))
(map #(update % :name (partial apply-level (or (:level %) 0))))
(print-table))))
(print-table options))))

;; Show changes URLs
(let [urls (->> deps
(filter :latest-version)
(sort u.dep/compare-deps)
(keep :changes-url)
(distinct))]
(when (seq urls)
(println "\nAvailable changes:")
(doseq [u urls]
(println "-" u)))))
(when-not (:changes-in-table options)
(let [urls (->> deps
(filter :latest-version)
(sort u.dep/compare-deps)
(keep :changes-url)
(distinct))]
(when (seq urls)
(println "\nAvailable changes:")
(doseq [u urls]
(println "-" u))))))

(defn- progress-text
[{:keys [width total-count current-count]}]
Expand Down

0 comments on commit 7e9af77

Please sign in to comment.