Improve error message

This commit is contained in:
Michiel Borkent 2021-03-24 17:04:01 +01:00
parent 4617076104
commit 29f4452fef
2 changed files with 9 additions and 1 deletions

View file

@ -551,7 +551,9 @@ Use -- to separate script command line args from bb command line args.
(if (str/ends-with? opt ".jar") (if (str/ends-with? opt ".jar")
:jar :file) opt :jar :file) opt
:command-line-args (next options)) :command-line-args (next options))
(error (str "File does not exist: " opt) 1))))))) (error (str (if (str/starts-with? opt ":")
"Task does not exist: "
"File does not exist: ") opt) 1)))))))
opts-map))] opts-map))]
opts)))) opts))))

View file

@ -20,6 +20,12 @@
(binding [test-utils/*bb-edn-path* (str bb-edn-file#)] (binding [test-utils/*bb-edn-path* (str bb-edn-file#)]
~@body))) ~@body)))
(deftest task-cli-test
(with-config {}
(is (thrown-with-msg?
Exception #"Task does not exist: :sum"
(bb :sum)))))
(deftest babashka-task-test (deftest babashka-task-test
(with-config {:tasks {:sum {:task/type :babashka (with-config {:tasks {:sum {:task/type :babashka
:task/args ["-e" "(+ 1 2 3)"]}}} :task/args ["-e" "(+ 1 2 3)"]}}}