Skip to content

Commit

Permalink
Fix #91: keyword options and hyphen options should not mix (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Mar 18, 2024
1 parent acdde51 commit d319f1f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ For breaking changes, check [here](#breaking-changes).

[Babashka CLI](https://github.com/babashka/cli): turn Clojure functions into CLIs!

## Unreleased

- Fix #91: keyword options and hyphen options should not mix

## v0.8.58 (2024-03-12)

Fix [#89](https://github.com/babashka/cli/issues/89): long option never represents alias
Expand Down
3 changes: 2 additions & 1 deletion src/babashka/cli.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@
(defn- parse-key [arg mode current-opt coerce-opt added]
(let [fst-char (first-char arg)
snd-char (second-char arg)
hyphen-opt? (and (= fst-char \-)
hyphen-opt? (and (not= :keywords mode)
(= fst-char \-)
(not (number-char? snd-char)))
mode (or mode (when hyphen-opt? :hyphens))
fst-colon? (= \: fst-char)
Expand Down
4 changes: 4 additions & 0 deletions test/babashka/cli_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -553,3 +553,7 @@

(deftest issue-89-alias-only-for-short-opt
(is (= {:f "dude"} (cli/parse-opts ["--f" "dude"] {:spec {:foo {:alias :f}}}))))

(deftest issue-91-keyword-mode-overrides-hypens-mode
(is (= {:args ["--baz"], :opts {:foo 1}}
(cli/parse-args [":foo" 1 "--baz"] {}))))

0 comments on commit d319f1f

Please sign in to comment.