hi, can you suggest any resources that explain how to build a command line application using boot?
@ajay.rivendell I would need more info but you can try http://github.com/degree9/boot-exec
Oh sorry that won’t help, boot isn’t designed for building cli apps
Yet ;)
Why not? E.g. https://github.com/boot-clj/boot/wiki/Scripts
I use this all the time
Ok, sorry, my question was misleading. I am not looking to turn a Clojure script into an executable. I just want to see an example of a command line application (fine to invoke through just boot some-task). Something beyond simple usage. Maybe 2-3 Clojure source files, how build.boot is defined, how profile.boot is defined etc.
@ajay.rivendell you can call any deftask from the command line using boot my-task
, no config needed
and you can make a standalone script as described in the mentioned link
e.g. this is a migrate script that I call from the cmd line:
#!/usr/bin/env boot
(set-env! :dependencies
'[[boot-bundle "0.1.0" :scope "test"]])
(require '[boot-bundle :refer [expand-keywords]])
(reset! boot-bundle/bundle-file-path "../bundle.edn")
(set-env!
:resource-paths #{"src"
"resources"}
:dependencies
(expand-keywords
'[;; Base
:base
:logging
:crispin
;; DB
[org.postgresql/postgresql "42.2.5"]
[migratus "1.0.6"]]))
(require '[dre.task.migrate :refer [migrate]])
(defn -main [& args]
(apply boot "migrate" args))
OK thanks! But I am NOT looking to create an executable script. My question is different
Yes, like I said: just call boot my-task
then.
and put some (deftask my-task ...)
in a build.boot file
Don’t know what else you’re asking for 🙂
How can I set a property in profile.boot and how do I read it in my Clojure source file? Do I need 'environ' for this or I can just use boot?
That does not compile to a cli app, it simply wraps boot - I originally thought they wanted a cli app with embedded boot
@ajay.rivendell then my link is correct for you!
boot-exec is what you want
Look at http://github.com/degree9/boot-npm for a usage example
@ajay.rivendell do you really want to set a property in your profile.boot? What are you trying to accomplish?
I would recommend storing it in the local project boot.properties if you have to, you can use boot-clj/bootstrap to read it. With bootstrap.config/config which returns the config map used by boot.
“compile to a cli app” you mean bundle a JVM, etc? It’s not clear to me that this is what Ajay wants… also, boot-exec doesn’t compile to a CLI app, it just executes other executables?
Correct