File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed
Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change 22
33## Added
44
5+ - Add source tracking (config provenance) for keys in the initial context
6+
57## Fixed
68
7- ## Changed
9+ - Only apply flag defaults if they are not yet present in the initial context
810
911# 0.22.87 (2025-02-09 / afd4eb0)
1012
Original file line number Diff line number Diff line change 296296
297297(defn add-defaults [init-opts flagpairs]
298298 (reduce (fn [opts flagspec]
299- (if-let [d (:default flagspec)]
300- (let [d (if (and (string? d) (:parse flagspec))
301- ((:parse flagspec default-parse ) d)
302- d)]
303- (if-let [h (:handler flagspec)]
304- (binding [*opts* opts] (h opts d))
305- (-> opts
306- (assoc (:key flagspec) d)
307- (assoc-in [::sources (:key flagspec)] (str (:flagstr flagspec) " (default value)" )))))
308- opts))
299+ (if (some? (get opts (:key flagspec)))
300+ opts
301+ (if-let [d (:default flagspec)]
302+ (let [d (if (and (string? d) (:parse flagspec))
303+ ((:parse flagspec default-parse ) d)
304+ d)]
305+ (if-let [h (:handler flagspec)]
306+ (binding [*opts* opts] (h opts d))
307+ (-> opts
308+ (assoc (:key flagspec) d)
309+ (assoc-in [::sources (:key flagspec)] (str (:flagstr flagspec) " (default value)" )))))
310+ opts)))
309311 init-opts
310312 (map second flagpairs)))
311313
397399 (dispatch* (to-cmdspec cmdspec) *command-line-args*))
398400 ([{:keys [flags init] :as cmdspec} cli-args]
399401 (let [init (if (or (fn? init) (var? init)) (init ) init)
402+ init (assoc init ::sources (into {} (map (fn [k] [k " Initial context" ])) (keys init)))
400403 [cmdspec pos-args flags] (split-flags cmdspec cli-args init)
401404 flagpairs (get cmdspec :flagpairs )]
402405 (dispatch* cmdspec pos-args flags)))
You can’t perform that action at this time.
0 commit comments