Skip to content

Commit

Permalink
Prevent false defaults from being removed/ignored (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
eval authored Mar 29, 2024
1 parent d319f1f commit 8cef8ad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 5 additions & 4 deletions src/babashka/cli.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion test/babashka/cli_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
Expand Down

0 comments on commit 8cef8ad

Please sign in to comment.