Skip to content

Commit 8917f5a

Browse files
committed
Fix scoping of cli/*opts*
1 parent d8c2c8f commit 8917f5a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Unreleased
22

3-
## Added
4-
53
## Fixed
64

7-
## Changed
5+
- Make sure `cli/*opts*` reflects what the main command receives
86

97
# 0.14.62 (2024-07-04 / 8a515f3)
108

src/lambdaisland/cli.clj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,12 @@
364364
(parse-error! "Missing required flags:" (->> missing (map #(str/join " " %)) (str/join ", ")))
365365
(cmd opts)))))
366366

367+
(defn bind-opts-mw []
368+
(fn [cmd]
369+
(fn [opts]
370+
(binding [*opts* opts]
371+
(cmd opts)))))
372+
367373
(defn dispatch*
368374
([cmdspec]
369375
(dispatch* (to-cmdspec cmdspec) *command-line-args*))
@@ -382,7 +388,8 @@
382388

383389
(cond
384390
command
385-
(let [middleware (into [(missing-flags-mw cmdspec)
391+
(let [middleware (into [(bind-opts-mw)
392+
(missing-flags-mw cmdspec)
386393
(help-mw cmdspec)]
387394
(::middleware opts))
388395
opts (-> opts

0 commit comments

Comments
 (0)