From 78cbdd1d82bc99c3fa913fabe40052e89295a52c Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 24 Sep 2022 04:59:34 -0400 Subject: [PATCH] #1336: --force as global opt (#1374) --- CHANGELOG.md | 1 + src/babashka/main.clj | 6 +++--- test/babashka/main_test.clj | 7 ++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a8ba632..e0e970bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ A preview of the next release can be installed from ## Unreleased +- [#1336](https://github.com/babashka/babashka/issues/1336): tasks subcommand doesn't work with global --force option ([@bobisageek](https://github.com/bobisageek)) - [#1340](https://github.com/babashka/babashka/issues/1340): `defprotocol` are methods missing `:doc` metadata ([@bobisageek](https://github.com/bobisageek)) - [#1368](https://github.com/babashka/babashka/issues/1368): `-x`: do not pick up on aliases in `user` ns - [#1367](https://github.com/babashka/babashka/issues/1367): Fix line number in clojure.test output ([@retrogradeorbit](https://github.com/retrogradeorbit)) diff --git a/src/babashka/main.clj b/src/babashka/main.clj index e089b0f3..784c5473 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -552,9 +552,6 @@ Use bb run --help to show this help output. ("--verbose") (recur (next options) (assoc opts-map :verbose? true)) - ("--force") (recur (next options) - (assoc opts-map - :force? true)) ("--describe") (recur (next options) (assoc opts-map :describe? true)) @@ -699,6 +696,9 @@ Use bb run --help to show this help output. ("--init") (recur (nnext options) (assoc opts-map :init (second options))) + ("--force") + (recur (next options) (assoc opts-map :force? true)) + ("--config") (recur (nnext options) (assoc opts-map :config (second options))) diff --git a/test/babashka/main_test.clj b/test/babashka/main_test.clj index 3973ea03..e645c82b 100644 --- a/test/babashka/main_test.clj +++ b/test/babashka/main_test.clj @@ -60,7 +60,12 @@ (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"]))) + (is (= {:force? true :list-tasks true :command-line-args nil} (parse-opts ["--force" "tasks"]))) + (is (= {:force? true :run "sometask" :command-line-args nil} (parse-opts ["--force" "run" "sometask"]))) + (is (= {:force? true :repl true} (parse-opts ["--force" "repl"]))) + (is (= {:force? true :clojure true :command-line-args '("-M" "-r")} + (parse-opts ["--force" "clojure" "-M" "-r"])))) (deftest version-test (is (= [1 0 0] (main/parse-version "1.0.0-SNAPSHOT")))