Fork me on GitHub
#boot
<
2019-02-28
>
ajay.rivendell16:02:33

hi, can you suggest any resources that explain how to build a command line application using boot?

flyboarder17:02:21

@ajay.rivendell I would need more info but you can try http://github.com/degree9/boot-exec

flyboarder17:02:03

Oh sorry that won’t help, boot isn’t designed for building cli apps

flyboarder18:02:04

That does not compile to a cli app, it simply wraps boot - I originally thought they wanted a cli app with embedded boot

borkdude18:02:36

“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?

borkdude17:02:53

I use this all the time

ajay.rivendell17:02:05

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.

borkdude17:02:54

@ajay.rivendell you can call any deftask from the command line using boot my-task, no config needed

borkdude17:02:12

and you can make a standalone script as described in the mentioned link

borkdude17:02:08

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))

ajay.rivendell17:02:32

OK thanks! But I am NOT looking to create an executable script. My question is different

borkdude17:02:04

Yes, like I said: just call boot my-task then.

borkdude17:02:26

and put some (deftask my-task ...) in a build.boot file

borkdude17:02:39

Don’t know what else you’re asking for 🙂

ajay.rivendell17:02:28

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?

flyboarder18:02:50

@ajay.rivendell then my link is correct for you!

flyboarder18:02:59

boot-exec is what you want

flyboarder18:02:29

@ajay.rivendell do you really want to set a property in your profile.boot? What are you trying to accomplish?

ajay.rivendell04:03:57

I wanted to just set some environment variable/config, for example url to some service, I couldn't figure it out how to do it in boot/environ

flyboarder04:03:14

ah ok, yeah we dont recommend using boot.properties that way, since thats what boot-environ is already for

flyboarder18:02:04

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.