This commit is contained in:
Michiel Borkent 2024-01-12 18:33:22 +01:00
parent ecbbd7ab84
commit 707e430bc5
3 changed files with 9 additions and 4 deletions

View file

@ -722,9 +722,10 @@ Use bb run --help to show this help output.
(let [opt (first options)]
(if (and opt (and (fs/exists? opt)
(not (fs/directory? opt))))
[(next options) (assoc opts-map
(if (str/ends-with? opt ".jar")
:jar :file) opt)]
[nil (assoc opts-map
(if (str/ends-with? opt ".jar")
:jar :file) opt
:command-line-args (next options))]
[options opts-map])))
(defn parse-opts
@ -1152,6 +1153,7 @@ Use bb run --help to show this help output.
(:jar opts))
(parse-file-opt args opts)
[args opts])
;; _ (prn :args args :opts opts)
abs-path #(-> % io/file .getAbsolutePath)
config (cond
config (if (fs/exists? config) (abs-path config)

View file

@ -0,0 +1 @@
(prn (first *command-line-args*))

View file

@ -1,6 +1,7 @@
(ns babashka.main-test
{:clj-kondo/config '{:linters {:unresolved-symbol {:exclude [working?]}}}}
(:require
[babashka.fs :as fs]
[babashka.main :as main]
[babashka.test-utils :as test-utils]
[clojure.edn :as edn]
@ -71,7 +72,8 @@
(-> (let [[_ opts] (main/parse-file-opt ["-e" "(prn :foo)"] {})]
(main/parse-opts ["-e" "(prn :foo)"] opts)))))
(is (= {:file "foo", :command-line-args ["README.md"]}
(main/parse-opts ["README.md"] {:file "foo"})))))
(main/parse-opts ["README.md"] {:file "foo"})))
(prn (bb nil (fs/file "test-resources" "script_with_overlapping_opts.clj") "--version"))))
(deftest version-test
(is (= [1 0 0] (main/parse-version "1.0.0-SNAPSHOT")))