Fork me on GitHub
#tools-deps
<
2018-06-11
>
delaguardo12:06:57

Is it possible to specify init-opt within deps.edn file?

bhauman17:06:09

should I be surprised that clojure forms in main opts are not output as quoted args?

bhauman17:06:51

I.E. :main-opts ["-e" (list 1 2 3)]

bhauman17:06:24

the list expression gets broken up into separate args

bhauman17:06:17

I guess escaping gets complicated

bhauman17:06:30

or there is a depth of features here I don't understand

hiredman17:06:02

I think the thing you might be missing is :main-opts is meant to be a list of strings passed as command line arguments, not a list of arbitrary datastructures

seancorfield17:06:39

Also remember that , is whitespace so you can often get around shell-level tokenization by using , in strings instead of spaces. But, yeah, :main-opts are strings @bhauman.

bhauman17:06:42

thanks guys

bhauman17:06:19

another question, is this not a feature that we might want?

bhauman17:06:27

to take advantage of the fact that we are in a clojure form to begin with and script our way to euphoria?

seancorfield17:06:36

But :main-opts are what is passed as a sequence of strings to the -main function via clojure.main -- it's all strings. You can easily pass an EDN string if you want a data structure.

seancorfield17:06:50

There's no difference between command-line invocation and :main-opts.

seancorfield17:06:20

and it is passed by a script, not by Clojure code.

bhauman17:06:06

the script doesn't parse the deps.edn

seancorfield17:06:15

The :main-opts are cached to a text file and then piped into the (string) options passed to clojure.main. Just like the :jvm-opts.

bhauman17:06:51

I get this but I'm sure clojure code prepares the opts

bhauman17:06:59

before caching

seancorfield17:06:07

It's just strings in the cached file. And it's just strings that are passed to clojure.main.

bhauman17:06:34

I must be missing something, are you saying that the feature isn't possible?

bhauman17:06:01

or that it messes up the semantics?

seancorfield17:06:26

Take a look at the clojure shell script. Here's an example of what gets cached:

(! 763)-> ls -l .cpcache/*.main
-rw-r--r--  1 sean  staff  90 Mar 26 15:38 .cpcache/1770942858.main
-rw-r--r--  1 sean  staff  17 Apr 14 00:52 .cpcache/2142975460.main
-rw-r--r--  1 sean  staff  17 Apr 14 18:18 .cpcache/4269137912.main
-rw-r--r--  1 sean  staff  22 May  2 14:38 .cpcache/84686696.main
(sean)-(jobs:0)-(~/clojure)
(! 764)-> cat .cpcache/84686696.main 
-m rebel-readline.main
(sean)-(jobs:0)-(~/clojure)
(! 765)-> cat .cpcache/1770942858.main 
-e (require,'[clojure.tools.nrepl.server,:refer,[start-server]]),(start-server,:port,5555)
(sean)-(jobs:0)-(~/clojure)
(! 766)-> 

bhauman17:06:48

yes but we call the tools.aplha to resolve the tags

bhauman17:06:20

which is parsing main opts and therefore could quote clojure forms before caching them?

hagmonk19:06:44

I just made a fairly big update to https://github.com/hagmonk/depify/ … would appreciate any folks here who could kick the tires a bit before I post to the mailing list

seancorfield19:06:23

This includes adding some test runner boilerplate from clj-new. -- not sure what you mean there @hagmonk?

seancorfield19:06:30

Should that link to Cognitect's test-runner repo perhaps?

hagmonk19:06:40

Oh I pinched that from a clj-new generated app - specifically the separate test and runner aliases

hagmonk19:06:40

I didn’t see the same style being used on the test-runner repo, but maybe I missed it

seancorfield19:06:10

Ah, I see. Linking to my dot-clojure repo probably makes more sense then for that https://github.com/seancorfield/dot-clojure/blob/master/deps.edn#L9-L19 (at least by way of explanation).

hagmonk19:06:44

Cool! I will make that change

hagmonk19:06:36

I’m exploring the idea of adding more aliases to provide parity with project.clj, in those cases where someone has a tools.deps based tool we can use

hagmonk19:06:48

CLJS and uberjars for instance

hagmonk19:06:43

so now I'm looking at your deps.edn file and getting lots of ideas :) but I need to work on my real projects today at some point, LOL

Alex Miller (Clojure team)20:06:15

@bhauman I didn’t understand your earlier comments re quoting. if it’s something I should pay attention to, please try again :)

bhauman20:06:35

happy to 🙂

Alex Miller (Clojure team)20:06:53

the ground truth is that the jvm takes a classpath, a main class and string args to the main class. so we want to expose that, first.

Alex Miller (Clojure team)20:06:08

other things on top of that may also be useful

bhauman20:06:14

absolutely

Alex Miller (Clojure team)20:06:36

but I didn’t understand what problem you were trying to solve or thing you were trying to make better or avoid

bhauman20:06:36

it just seems there is an opportunity when providing clojure forms (not strings) inline in :main-opts to output a single string arg that will make it through to the jvm process as a single arg

Alex Miller (Clojure team)20:06:58

the ultimate call needs individual string args though - how do you decide how to parse and tokenize?

bhauman20:06:21

:main-opts ["-e" {:build 1}] => clojure -e "{:build 1}"

bhauman20:06:36

is what I'm imagining

Alex Miller (Clojure team)20:06:39

you seem to be suggesting a read/print cycle but using different kinds of printing

Alex Miller (Clojure team)20:06:34

“-e” would be read as a string and pr’ed as “-e” (perhaps escaped in the invocation as clojure -e '"-e"`

bhauman20:06:16

it seems that string typs can go though untouched and that forms would be dispatched as such

bhauman20:06:27

other than string forms 🙂

bhauman20:06:53

its a common need, and it seems like a shame to be in a clojure form and then have to translate and escape a clojrue form correctly

Alex Miller (Clojure team)20:06:31

there are a couple layers of transformation here and I intend to sit down and sort through them methodically. I’m well aware it’s broken in various ways at the moment.

Alex Miller (Clojure team)20:06:57

I’m a little concerned about implying evaluation in the deps.edn file

Alex Miller (Clojure team)20:06:27

the args there are read (as edn) and never evaluated and I don’t want to imply that (or do it)

Alex Miller (Clojure team)20:06:48

it’s important to me that it remains plain edn data

bhauman20:06:11

absolutely

bhauman20:06:03

not what I'm thinking or wanting to imply at all

Alex Miller (Clojure team)20:06:22

I didn’t think so, but it’s easy to get that impression from that example

Alex Miller (Clojure team)20:06:55

I’m not a fan of “special” arg handling

bhauman20:06:57

where I really want it is for cljs.main and figwheel.main to supply inline config

Alex Miller (Clojure team)20:06:25

yeah, that’s really same need as say, server repl

Alex Miller (Clojure team)20:06:49

passing arbitrary edn as an arg

bhauman20:06:04

:main-opts ["-m" "cljs.main" "-co" {:output-to "out/main.js"} ]

Alex Miller (Clojure team)20:06:19

in a way that is not a nightmare, and that works :)

bhauman20:06:35

what works?

Alex Miller (Clojure team)20:06:47

I’m just saying that a requirement is that the end result works

bhauman20:06:03

gotcha 🙂

bhauman20:06:16

it is interesting though that I'd expected this to work

bhauman20:06:37

I intuited that it might me a likely feature

Alex Miller (Clojure team)20:06:59

there might be a higher level solution to this problem too - I know Rich has mentioned various ideas that are in this ballpark but a somewhat different take on it

Alex Miller (Clojure team)20:06:47

for example, you could expose functions directly and hide the main goo entirely

bhauman20:06:06

that is interesting

Alex Miller (Clojure team)20:06:28

it’s come up in several contexts and I know he’s noodling about it

Alex Miller (Clojure team)20:06:52

but sometimes he noodles for many years before it lands somewhere :)

Alex Miller (Clojure team)20:06:23

so I make no suggestion that a deux ex machina will save us all here

Alex Miller (Clojure team)20:06:07

clojure.main itself is both very flexible and frustratingly limited

Alex Miller (Clojure team)20:06:38

like I think it sucks that rebel-readline couldn’t just be hooked directly

bhauman20:06:57

I had some thoughts about that

bhauman20:06:43

I could potentially graalvm it, and provide a rlwrap equivalent

Alex Miller (Clojure team)20:06:44

well, I need to roll back to other work, but I would like to hear them somewhere :)

bhauman20:06:05

thanks Alex! later