This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-08
Channels
- # aleph (9)
- # announcements (42)
- # babashka (13)
- # babashka-sci-dev (9)
- # beginners (38)
- # biff (1)
- # calva (4)
- # cider (5)
- # clj-kondo (39)
- # cljdoc (4)
- # cljsrn (3)
- # clojure (93)
- # clojure-bay-area (1)
- # clojure-czech (1)
- # clojure-dev (4)
- # clojure-europe (65)
- # clojure-finland (3)
- # clojure-nl (2)
- # clojure-norway (7)
- # clojure-portugal (1)
- # clojure-uk (2)
- # clojurescript (73)
- # cloverage (1)
- # cursive (5)
- # data-science (1)
- # datahike (22)
- # emacs (51)
- # graalvm (6)
- # introduce-yourself (8)
- # jobs-discuss (14)
- # kaocha (6)
- # mount (5)
- # nbb (19)
- # off-topic (19)
- # reagent (5)
- # releases (1)
- # sci (19)
- # scittle (4)
- # shadow-cljs (6)
- # tools-deps (9)
- # xtdb (2)
Hi all! Is it possible in bb tasks to evaluate a symbol? Like instead of:
# bb.edn
{:tasks
foo-bar foo.bar/-main}
to have something like:
{:tasks
foo-bar (symbol "foo.bar" "-main")}
It's not returning errors, but it doesn't seem to do anything either (like it's rather returning the symbol than evaluating it). Using resolve
returns nil
.Hi @UUAKPEMJ9! Is your goal to execute a main function dynamically?
Hmm, I'm still learning clj, so I may be confusing something. My goal is actually to create the symbol to be evaluated from the command line args (context: writing a setup for Advent of Code in bb, and want to have task to run solution for a puzzle of a given day, like bb solve 1
. I'd have a namespace day1.solution
with a -main
func there. But each day will add another namespace, and I don't want to update tasks each day bc I want to automate stuff 🙂).
that gets you the var, but then you still need to call that a function:
(apply (requiring-resolve (symbol "foo.bar" "-main")) *command-line-args*)
or just
((requiring-resolve (symbol "foo.bar" "-main")))
if you don't want to feed it any command line argsExcellent -- that works! Thank you 🙂
What this does is it parses the command line arguments with babashka.cli and then executes the function denoted by the symbol foo.bar/baz with those arguments
And that works, too