diff --git a/src/babashka/main.clj b/src/babashka/main.clj index 1e47bf4d..9ec771fc 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -585,8 +585,8 @@ Use bb run --help to show this help output. (update opts-map :expressions (fnil conj []) (first options)))) ("--main", "-m",) (let [options (next options)] - (recur (next options) - (assoc opts-map :main (first options)))) + (assoc opts-map :main (first options) + :command-line-args (rest options))) ("--run") (parse-run-opts opts-map (next options)) ("--tasks") diff --git a/test/babashka/main_test.clj b/test/babashka/main_test.clj index 80bd103f..3b10f9f7 100644 --- a/test/babashka/main_test.clj +++ b/test/babashka/main_test.clj @@ -54,7 +54,8 @@ (let [v (bb nil "--describe")] (is (:babashka/version v)) (is (:feature/xml v))) - (is (= {:force? true} (main/parse-opts ["--force"])))) + (is (= {:force? true} (main/parse-opts ["--force"]))) + (is (= {:main "foo", :command-line-args '("-h")} (main/parse-opts ["-m" "foo" "-h"])))) (deftest version-test (is (= [1 0 0] (main/parse-version "1.0.0-SNAPSHOT"))) @@ -217,7 +218,6 @@ (testing "init with a task name after it" (test-utils/with-config '{:tasks {thing (println (init-test/do-a-thing))}} ; make a task available (is (= "foo\n" (test-utils/bb nil "--init" "test-resources/babashka/init_test.clj" "thing")))))) - (deftest preloads-test ;; THIS TEST REQUIRES: diff --git a/test/babashka/uberscript_test.clj b/test/babashka/uberscript_test.clj index ee7d11cd..b7d39683 100644 --- a/test/babashka/uberscript_test.clj +++ b/test/babashka/uberscript_test.clj @@ -1,17 +1,16 @@ (ns babashka.uberscript-test (:require [babashka.test-utils :as tu] - [clojure.edn :as edn] [clojure.test :as t :refer [deftest is testing]])) (deftest uberscript-test (let [tmp-file (java.io.File/createTempFile "uberscript" ".clj")] (.deleteOnExit tmp-file) - (is (empty? (tu/bb nil "--classpath" "test-resources/babashka/src_for_classpath_test" "-m" "my.main" "--uberscript" (.getPath tmp-file)))) + (is (empty? (tu/bb nil "--classpath" "test-resources/babashka/src_for_classpath_test" "uberscript" (.getPath tmp-file) "-m" "my.main" ))) (is (= "(\"1\" \"2\" \"3\" \"4\")\n" (tu/bb nil "--file" (.getPath tmp-file) "1" "2" "3" "4"))) (testing "order of namespaces is correct" - (tu/bb nil "--classpath" "test-resources/babashka/uberscript/src" "-m" "my.main" "--uberscript" (.getPath tmp-file)) + (tu/bb nil "--classpath" "test-resources/babashka/uberscript/src" "uberscript" (.getPath tmp-file) "-m" "my.main") (is (= "(\"1\" \"2\" \"3\" \"4\")\n" (tu/bb nil "--file" (.getPath tmp-file) "1" "2" "3" "4"))))))