diff --git a/CHANGELOG.md b/CHANGELOG.md index cdbc991..e321c66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,8 @@ For breaking changes, check [here](#breaking-changes). ## Unreleased -- Fix #91: keyword options and hyphen options should not mix +- Fix [#96](https://github.com/babashka/cli/issues/96): prevent false defaults from being removed/ignored +- Fix [#91](https://github.com/babashka/cli/issues/91): keyword options and hyphen options should not mix ## v0.8.58 (2024-03-12) diff --git a/src/babashka/cli.cljc b/src/babashka/cli.cljc index 6bb0bef..c510553 100644 --- a/src/babashka/cli.cljc +++ b/src/babashka/cli.cljc @@ -197,8 +197,9 @@ (assoc aliases alias k))) require (update :require (fnil #(conj % k) #{})) validate (update :validate assoc k validate) - default (update :exec-args (fn [new-exec-args] - (assoc new-exec-args k (get exec-args k default)))))) + (some? default) (update :exec-args + (fn [new-exec-args] + (assoc new-exec-args k (get exec-args k default)))))) {} spec))) @@ -560,8 +561,8 @@ (when (:ref columns) (if ref ref "")) (when (or (:default-desc columns) - (:default columns)) - (str (or default-desc default ""))) + (some? (:default columns))) + (str (or default-desc (str default) ""))) (when (:desc columns) (if desc desc ""))])) (if (map? spec) diff --git a/test/babashka/cli_test.cljc b/test/babashka/cli_test.cljc index a7d1405..fe2fa1a 100644 --- a/test/babashka/cli_test.cljc +++ b/test/babashka/cli_test.cljc @@ -203,10 +203,11 @@ :exec-args {:from :edn, :to :json, :paths ["src" "test"]}} (cli/spec->opts spec nil))) (is (= (str/trim " - -p, --pretty Pretty-print output. + -p, --pretty false Pretty-print output. --paths src test Paths of files to transform. ") (str/trim (cli/format-opts {:spec [[:pretty {:desc "Pretty-print output." + :default false :alias :p}] [:paths {:desc "Paths of files to transform." :coerce []