File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Unreleased
22
3- ## Added
4-
5- ## Fixed
6-
73## Changed
84
5+ - When there are a large number of flags/subcommands, split the synopsis across
6+ multiple lines, breaking at 120 characters
7+
98# 1.28.124 (2026-04-10 / 37a0800)
109
1110## Fixed
Original file line number Diff line number Diff line change 5050(defn long? [f]
5151 (re-find #"^--.*" f))
5252
53+ (defn spill-lines [segments width]
54+ (reduce
55+ (fn [acc seg]
56+ (if (< (+ (count (last acc)) (count seg)) width)
57+ (update acc (dec (count acc)) str " " seg)
58+ (conj acc seg)))
59+ [" " ]
60+ segments))
61+
5362(defn print-help [cmd-name doc command-pairs argnames flagpairs]
5463 (let [desc #(str (first (str/split (:doc % " " ) #"\R " ))
5564 (when-let [d (:default %)] (str " (default " (pr-str d) " )" )))
6069 (println )
6170
6271 (println " SYNOPSIS" )
63- (println (str " " cmd-name
64- (when (seq argnames)
65- (str/join (for [n argnames]
66- (str " <" (name n) " >" ))))
67- (str/join (for [[_ {:keys [flags argdoc]}] flagpairs]
68- (str " [" (str/join " | " flags) argdoc " ]" )))
69- (when (seq command-pairs)
70- (str " ["
71- (str/join " | " (for [[cmd cmdopts] command-pairs
72- :when (not (:no-doc cmdopts))]
73- cmd))
74- " ]" ))
75- " [<args>...]" ))
72+ (let [[l & ls] (spill-lines (concat [cmd-name]
73+ (for [n argnames]
74+ (str " <" (name n) " >" ))
75+ (for [[_ {:keys [flags argdoc]}] flagpairs]
76+ (str " [" (str/join " | " flags) argdoc " ]" ))
77+ (when (seq command-pairs)
78+ [(str " ["
79+ (str/join " | " (for [[cmd cmdopts] command-pairs
80+ :when (not (:no-doc cmdopts))]
81+ cmd))
82+ " ]" )])
83+ [" [<args>...]" ])
84+ 120 )]
85+ (println " " l)
86+ (run! #(println " " %) ls))
7687 (when-let [doc (next doc-lines)]
7788 (println " \n DESCRIPTION" )
7889 (println " " (str/join " \n " (map str/trim (drop-while #(str/blank? %) doc)))))
You can’t perform that action at this time.
0 commit comments