A way to make scripting doable in clojure(script)


#1

clojure --deps scriptA.clj.deps.edn scriptA.clj
clj --deps scriptA.clj.deps.edn scriptA.clj

If clojure and clj were able to specify path to deps.edn with such an option as --deps, planck could make use of this option through its plk executable. So, both clojure and clojurescript obtain a way to easily edit dependencies for each clojure(script) script.

#!/bin/sh
"exec" "plk" "--deps" "scriptA.clj.deps.edn" "$0" "[email protected]"
(require 'blah)

(println "good night")

#2

Not sure I get this? you want to change this in Clj or Planck?


#3

In clj. Planck will just inherit command line arguments from clj because planck uses clojure to do dependency resolution.


#4

You should be able to use -Sdeps "$(cat path/to/file/edn)"


#5

Damn, that is genius.


#6

Unfortunately, -Sdeps "$(cat path/to/file/edn)" suffers from the fact that I have to specify an absolute path to edn if I wanted to call the script anywhere.

I guess it would be better to specify -Sdeps for each dependency.


#7

Where do you want the deps.edn file to come from? The same directory as the shell script itself? Then use:

"$(cat `dirname $0`/deps.edn)"

#8

When there are spaces in the path to deps.edn, “$(cat dirname $0/deps.edn)” breaks down.


#9

Maybe wrap dirname $0/deps.edn in double quotes too ?


#10

I tried it. It doesn’t work.


#11

Lots of tooling breaks when there are spaces in filesystem paths – the solution is to not use such paths.

Even on Windows, you can avoid filesystem paths with spaces if you stay outside Windows’ own system folders (and you should).