Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent false defaults from being removed/ignored #97

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading