Fork me on GitHub
#babashka
<
2021-03-20
>
borkdude13:03:43

@grazfather I settled on :and-do and :or-do:

(testing ":and-do failing"
    (with-config {:tasks {:div-by-zero {:task/type :babashka
                                        :args ["-e" "(/ 1 0)"]}
                          :sum {:task/type :babashka
                                :args ["-e" "(+ 1 2 3)"]}
                          :all {:task/type :babashka
                                :args [:do :div-by-zero :and-do :sum]}}}
      (is (thrown-with-msg? Exception #"Divide"
                            (bb :all)))))
  (testing ":or-do succeeding"
    (with-config {:tasks {:div-by-zero {:task/type :babashka
                                        :args ["-e" "(/ 1 0)"]}
                          :sum {:task/type :babashka
                                :args ["-e" "(+ 1 2 3)"]}
                          :all {:task/type :babashka
                                :args [:do :div-by-zero :or-do :sum]}}}
      (is (= 6 (bb :all)))))

borkdude13:03:42

which may not be the correct name either, since :or will imply something like short-cutting on the first non-failing one, but I was thinking of || in the shell. Maybe I should have another one... :always-do ?

borkdude13:03:42

I think the bash equivalent of that is ;

borkdude13:03:53

:regardless-do ?

borkdude13:03:12

or just :do

borkdude13:03:24

yeah, that might work

grazfather13:03:50

or-do makes sense to me but I get how it could sound confusing

grazfather13:03:26

it could be misleading in a few ways

grazfather13:03:39

and-do might imply short-circuiting (do the first that succeeds and stop)

borkdude13:03:49

I now implemented :or-do as shortcutting

borkdude13:03:03

same as && and || in the shell

borkdude13:03:10

and just :do will always continue

borkdude13:03:15

:do :foo :do :bar