Skip to content

Commit

Permalink
Fix scoping of cli/*opts*
Browse files Browse the repository at this point in the history
  • Loading branch information
plexus committed Jul 16, 2024
1 parent d8c2c8f commit 8917f5a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Unreleased

## Added

## Fixed

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

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

Expand Down
9 changes: 8 additions & 1 deletion src/lambdaisland/cli.clj
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@
(parse-error! "Missing required flags:" (->> missing (map #(str/join " " %)) (str/join ", ")))
(cmd opts)))))

(defn bind-opts-mw []
(fn [cmd]
(fn [opts]
(binding [*opts* opts]
(cmd opts)))))

(defn dispatch*
([cmdspec]
(dispatch* (to-cmdspec cmdspec) *command-line-args*))
Expand All @@ -382,7 +388,8 @@

(cond
command
(let [middleware (into [(missing-flags-mw cmdspec)
(let [middleware (into [(bind-opts-mw)
(missing-flags-mw cmdspec)
(help-mw cmdspec)]
(::middleware opts))
opts (-> opts
Expand Down

0 comments on commit 8917f5a

Please sign in to comment.