fix #1143: allow optional (ignored) -- when using using --main (#1147)

Permits previously-accepted behavior broken in 19415f6363
This commit is contained in:
Michael Glaesemann 2022-01-20 07:53:54 -06:00 committed by GitHub
parent 3602b89512
commit ca59f3890e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -601,7 +601,9 @@ Use bb run --help to show this help output.
("--main", "-m",)
(let [options (next options)]
(assoc opts-map :main (first options)
:command-line-args (rest options)))
:command-line-args (if (= "--" (second options))
(nthrest options 2)
(rest options))))
("--run")
(parse-run-opts opts-map (next options))
("--tasks")

View file

@ -59,7 +59,8 @@
(is (:babashka/version v))
(is (:feature/xml v)))
(is (= {:force? true} (parse-opts ["--force"])))
(is (= {:main "foo", :command-line-args '("-h")} (parse-opts ["-m" "foo" "-h"]))))
(is (= {:main "foo", :command-line-args '("-h")} (parse-opts ["-m" "foo" "-h"])))
(is (= {:main "foo", :command-line-args '("-h")} (parse-opts ["-m" "foo" "--" "-h"]))))
(deftest version-test
(is (= [1 0 0] (main/parse-version "1.0.0-SNAPSHOT")))