diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dea77f..2a7cc39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/lambdaisland/cli.clj b/src/lambdaisland/cli.clj index 7f6f8d5..9701b91 100644 --- a/src/lambdaisland/cli.clj +++ b/src/lambdaisland/cli.clj @@ -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*)) @@ -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