Skip to content
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
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

- [#126](https://github.com/babashka/cli/issues/126): `-` value accidentally parsed as option, e.g. `--file -`

## v0.8.66 (2025-07-12)

- [#122](https://github.com/babashka/cli/issues/122): introduce new
Expand Down
3 changes: 2 additions & 1 deletion src/babashka/cli.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
(try
(let [s ^String s
fst-char (first-char s)
#?@(:clj [leading-num-char (if (= fst-char \-)
#?@(:clj [leading-num-char (if (= \- fst-char)
(second-char s)
fst-char)])]
(cond (or (= "true" s)
Expand Down Expand Up @@ -239,6 +239,7 @@
snd-char (second-char arg)
hyphen-opt? (and (not= :keywords mode)
(= \- fst-char)
(> (count arg) 1)
(let [k (keyword (subs arg 1))]
(or
(contains? known-keys k)
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 @@ -654,3 +654,7 @@
(cli/parse-args ["--foo" "1" "--foo" "2"] {:repeated-opts true :spec {:foo {:coerce []}}})))
(is (= {:args ["2"], :opts {:foo [1]}}
(cli/parse-args ["--foo" "1" "2"] {:repeated-opts true :spec {:foo {:coerce []}}}))))

(deftest issue-126-test
(is (= {:file "-"} (cli/parse-opts ["--file" "-"])))
(is (= {:file "-"} (cli/parse-opts ["-"] {:args->opts [:file]}))))