@salkadam Yes if you look at the discussion here over the past little while as borkdude suggested you'll see I had the same issues trying to generate a Luminus template. You can see I found a way to invoke it with a commandline interface that doesn't involve passing strings: https://github.com/practicalli/clojure-deps-edn#create-new-projects-from-templates Use the classic approach there as opposed to the recommended approach (which is the same method you are already trying). Or alternatively you can install WSL2 as seancorfield suggests which lets you work on Linux from within Windows and shouldn't have the problems with passing the string arguments as they are displayed.
This works for me:
Projects $ clojure -X:project/new :template figwheel-main :name yourname/hello-world :args '[\"--reagent\"]'
Generating fresh figwheel-main project.
To get started:
--> Change into the 'hello-world' directory
--> Start build with 'clojure -A:fig:build'
it's slightly different command, but it should not matter, rather the escaping exampleso the command snippet from @jr0cket tutorial that @flyingpython suggested would look like this (example):
Projects $ clojure -X:project/new :template luminus :name practicalli/full-stack-app :args '[\"+http-kit\" \"+h2\"]'
Generating a Luminus project.
I think I'll try to reach @jr0cket and ask to work with him if we can make the commands work properly on Windows.
@ales.najmann note that the above works in PS but probably not in cmd.exe
Perhaps the clj tool can be told to read the EDN args from a file? This would work in all shells. @alexmiller
So if I understand correctly, the solution for Windows native command line is to escape the double quotes in the command. I can add a note about that to the Practicalli configuration.
Seems to be the case.
Ah, according to Borkdude it's not the case for CMD.exe
Understand. I'll check. I just want to point out, you will likely won't be able to install Clojure on the machine without Powershell. So I would suggest to stick to a single way to use it. And I hope I'm not doing "works on my machine" kind of reply myself 😄
As of now that is true because the CLI tools on Windows cornered themselves in some powershell function. This comes with trade offs like not being able to shell out to it from java without magic. Bb and deps.clj do not have these downsides and still work properly in cmd.exe. In the conversation above i showed how you can debug how cmd line args are parsed as EDN in both cmd.exe and powershell
Bb comes with ‘bb clojure ...’ subcommand which should work identically to the Clojure CLI
@salkadam if a template and set of option is used quite regularly, then a work-around could be to add a specific alias with the template and options already define.
Calling this alias then reads the template options configuration from the ~/.clojure/deps.edn
file.
I appreciate this is not ideal.
I guess you could also do that as a one off in your local deps.edn to bootstrap the project
That's interesting.
I mean I just wanted to provide positive, working examples. I'll have to take a look at babashka itself, at minimum what it can offer in this regard.
Well you can put :exec-args in your deps.edn
There are some ugly details. I would suggest not to use CMD.exe at all. Even if you execute cmd-clj it launches powershell, tooling etc. and then you're in complete escaping hell.
true!
So maybe that could be the recommended workaround for Windows
great suggestions, i will try those, the bigger issue for me is too convince us(IT) to move away from windows
that is more difficult compared to clj args
@salkadam I’m curious about whether your IT folks would allow using WSL2 on Windows?
that's possibly difficult too, i just added a new alias in ~/.clojure/deps.edn
:new-reagent {:extra-deps {seancorfield/clj-new {:mvn/version "1.1.293"}} :exec-fn clj-new/create :exec-args {:args ["--reagent"]}}
And it worked, so i am finethanks
...to confuse things even more, this appear to be correct too, and likely even more correct according to Powershell escaping rules:
Projects $ clojure -X:project/new :template luminus :name practicalli/full-stack-app :args "[\`"+http-kit\`" \`"+h2\`"]"
Downloading: luminus/lein-template/maven-metadata.xml from clojars
Generating a Luminus project.
Not sure if this helps because I don't fully understand/remember how escaping works in powershell, but I have had luck with this kind of escaping to pass a string arg in powershell
clj -X my.ns/fn :str-arg '"""my-string"""'