Skip to content

Commit

Permalink
Merge pull request #60 from pmonks/dev
Browse files Browse the repository at this point in the history
Release 2.0.241
  • Loading branch information
pmonks authored Jun 14, 2024
2 parents 03e890e + f5fee8a commit 66971cc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
4 changes: 2 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
{:deps
{jansi-clj/jansi-clj {:mvn/version "1.0.3"}
com.github.pmonks/clj-wcwidth {:mvn/version "1.0.85"}
com.github.pmonks/lice-comb {:mvn/version "2.0.321"}
com.github.pmonks/asf-cat {:mvn/version "2.0.139"}
com.github.pmonks/lice-comb {:mvn/version "2.0.327"}
com.github.pmonks/asf-cat {:mvn/version "2.0.145"}
com.github.pmonks/tools-convenience {:mvn/version "1.0.154"}}
:aliases
{:build {:deps {com.github.pmonks/pbr {:mvn/version "RELEASE"}
Expand Down
26 changes: 25 additions & 1 deletion src/tools_licenses/tasks.clj
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,30 @@
(str s padding)
(str padding s))))))))

(defn- split-long-lines-and-indent
"Splits any lines longer than w on the last whitespace, inserts a line break
and indents the remainder. The final line is also padded out to w."
[w s]
(when (and w s)
(if (<= (wcw/display-width s) w)
(fit-width w s)
(let [words (s/split s #"\s+")
lines (loop [result []
line ""
next-word (first words)
rem-words (rest words)]
(if-not next-word
(conj result line)
(let [new-line (s/trim (str line " " next-word))]
(if (> (wcw/display-width new-line) (- w 2))
(recur (conj result line) next-word (first rem-words) (rest rem-words))
(recur result new-line (first rem-words) (rest rem-words))))))
first-line (first lines)
rest-lines (map (partial str " ") (rest lines))
last-line (fit-width w (last rest-lines))
lines (concat [first-line] (take (dec (count rest-lines)) rest-lines) [last-line])]
(s/join "\n" lines)))))

(defn- summary-output!
"Emit summary output to stdout."
[proj-expressions-info deps-lib-map-with-info]
Expand All @@ -128,7 +152,7 @@
"\n------------------------------------------------------------ ---------"))
(if (or deps-expressions (pos? no-license-count))
(do
(run! #(println (str (fit-width 60 (human-readable-expression %)) " " (fit-width 9 (ansi/default (str (get freqs %))) false))) deps-expressions)
(run! #(println (str (split-long-lines-and-indent 60 (human-readable-expression %)) " " (fit-width 9 (ansi/default (str (get freqs %))) false))) deps-expressions)
(when (pos? no-license-count) (println (str (fit-width 60 (ansi/fg-bright :red "No licenses found")) " " (fit-width 9 no-license-count false)))))
(println " - no dependencies found -"))

Expand Down

0 comments on commit 66971cc

Please sign in to comment.