diff --git a/API.md b/API.md index d3f3a37..5d37a03 100644 --- a/API.md +++ b/API.md @@ -85,21 +85,21 @@ Subcommand dispatcher. Each entry in the table may have additional [`parse-args`](#parse-args) options. For more information and examples, see [README.md](README.md#subcommands). -
[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L671-L703) +
[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L672-L704) ## `format-opts` ``` clojure (format-opts {:as cfg, :keys [indent], :or {indent 2}}) ``` -[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L570-L574) +[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L571-L575) ## `format-table` ``` clojure (format-table {:keys [rows indent]}) ``` -[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L530-L541) +[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L531-L542) ## `merge-opts` ``` clojure @@ -122,21 +122,21 @@ Merges babashka CLI options. (opts->table {:keys [spec order]}) ``` -[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L551-L568) +[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L552-L569) ## `pad` ``` clojure (pad len s) ``` -[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L520-L520) +[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L521-L521) ## `pad-cells` ``` clojure (pad-cells rows) ``` -[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L522-L528) +[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L523-L529) ## `parse-args` ``` clojure @@ -147,7 +147,7 @@ Merges babashka CLI options. Same as [`parse-opts`](#parse-opts) but separates parsed opts into `:opts` and adds `:cmds` and `:rest-args` on the top level instead of metadata. -
[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L498-L505) +
[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L499-L506) ## `parse-cmds` ``` clojure @@ -207,9 +207,9 @@ Parse the command line arguments `args`, a seq of strings. ;; => throws 'Unknown option --qux' exception b/c there is no :qux key in the spec ``` -
[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L259-L496) +
[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L259-L497) ## `rows` -[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L544-L546) +[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L545-L547) ## `spec->opts` ``` clojure diff --git a/CHANGELOG.md b/CHANGELOG.md index 1478537..300a26d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ For breaking changes, check [here](#breaking-changes). [Babashka CLI](https://github.com/babashka/cli): turn Clojure functions into CLIs! +## v0.8.58 (2024-03-12) + +Fix [#89](https://github.com/babashka/cli/issues/89): long option never represents alias + ## v0.8.57 (2024-02-22) Fix [#82](https://github.com/babashka/cli/issues/82): prefer alias over composite option diff --git a/src/babashka/cli.cljc b/src/babashka/cli.cljc index 1bc69ab..d907bc3 100644 --- a/src/babashka/cli.cljc +++ b/src/babashka/cli.cljc @@ -377,7 +377,8 @@ (str/split kname #"=") [kname]) raw-k (keyword kname) - alias (get aliases raw-k) + alias (when-not long-opt? + (get aliases raw-k)) k (or alias raw-k)] (if arg-val (recur (process-previous acc current-opt added collect-fn) diff --git a/test/babashka/cli_test.cljc b/test/babashka/cli_test.cljc index 5dde95c..bf1459f 100644 --- a/test/babashka/cli_test.cljc +++ b/test/babashka/cli_test.cljc @@ -545,3 +545,6 @@ (is (= {:opts {:verbose2 true}} (cli/parse-args ["-vv"] {:spec {:verbose1 {:alias :v} :verbose2 {:alias :vv}}})))) + +(deftest issue-89-alias-only-for-short-opt + (is (= {:f "dude"} (cli/parse-opts ["--f" "dude"] {:spec {:foo {:alias :f}}}))))