This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-21
Channels
- # aws (2)
- # bangalore-clj (1)
- # beginners (25)
- # boot (2)
- # cider (176)
- # clara (73)
- # cljs-dev (6)
- # cljsrn (31)
- # clojure (40)
- # clojure-greece (9)
- # clojure-india (1)
- # clojure-italy (14)
- # clojure-nl (9)
- # clojure-russia (4)
- # clojure-uk (156)
- # clojurescript (124)
- # core-async (37)
- # cursive (2)
- # data-science (2)
- # datomic (22)
- # emacs (3)
- # fulcro (32)
- # graphql (6)
- # java (3)
- # lein-figwheel (19)
- # lumo (29)
- # nyc (1)
- # off-topic (9)
- # onyx (15)
- # portkey (12)
- # precept (2)
- # re-frame (15)
- # reagent (10)
- # rum (7)
- # schema (2)
- # shadow-cljs (48)
- # tools-deps (35)
- # yada (1)
Standalone script using tools.deps: https://github.com/borkdude/balcony
@alexmiller @dominicm thanks for TDEPS-9 - using Datomic PRO with clj
is rad
@robert-stuttaford I setup the JUXT website last night, was nice 🙂
i recognise this may be a daft question, but is there perhaps a way to run two ‘mains’ at once from clj
? i see the docs say that it’ll run the last one encountered, but i’m hoping to get a boot-like thing going where i can run both figwheel-main and my 10-liner CIDER repl script in one process
@robert-stuttaford Update to cider 0.17 and use -e
before your normal -m
-reads about -e
-
https://github.com/clojure-vim/vim-jack-in/blob/master/autoload/jack_in.vim#L56-L70 -e
is eval
^^ this might be useful to see what cider generates when it does jack-in, and hard-code it in 🙂
i’ve got a working cider script:
(require '[clojure.tools.nrepl.server :refer [start-server]]
'[refactor-nrepl.middleware :refer [wrap-refactor]])
(defn nrepl-handler []
(require 'cider.nrepl)
(ns-resolve 'cider.nrepl 'cider-nrepl-handler))
(def port 7800)
(spit ".nrepl-port" port)
(start-server :port port :handler (wrap-refactor (nrepl-handler)))
(println "Started nREPL on port" port)
(.addShutdownHook (Runtime/getRuntime)
(Thread. #( ".nrepl-port")))
i want to run it and figwheel-main together, in one process. right now i use two
Are you using cljs? That doesn't look like it will work with cljs. Unless you have a separate nrepl for figwheel?
hmm, i guess there’s no way around it; i’ll have to write a clj script that starts the nrepl-server and invokes the figwheel-main stuff afterwards
You can replace that whole file with:
clj -e "(require 'cider-nrepl.main) (cider-nrepl.main/init '[refactor-nrepl.middleware/wrap-refactor])"
@robert-stuttaford Apparently not, but mains can run other mains.
(defn -main [& args]
(start-nrepl)
(apply clojure.repl/main args))
turns out the figwheel-main api is super simple, this was a total non-issue
;; nREPL
(require '[clojure.tools.nrepl.server :refer [start-server]]
'[refactor-nrepl.middleware :refer [wrap-refactor]])
(defn nrepl-handler []
(require 'cider.nrepl)
(ns-resolve 'cider.nrepl 'cider-nrepl-handler))
(def port 7800)
(spit ".nrepl-port" port)
(start-server :port port :handler (wrap-refactor (nrepl-handler)))
(println "Started nREPL on port" port)
(.addShutdownHook (Runtime/getRuntime)
(Thread. #( ".nrepl-port")))
;; Figwheel
(require '[figwheel.main :refer [start]])
(start "dev")
With the new clojure
CLI tool, can I have a standalone .clj
script, i.e. apart from a src/
directory and without a corresponding deps.edn
file, ideally invokable via a simple shebang line (`#!`) at the top of the file? If so, what would that shebang line be?
#!/bin/sh
"exec" "clojure" "-Sdeps" '{:deps {funcool/tubax {:mvn/version "0.2.0"}}}' "$0" "$@"
(println "5555")
Impressive. Thanks, @dominicm! I'm assuming the :deps
are optional?
@jeff.terrell what do you mean optional?
As in, I don't need any deps. I can just leave that part out, right?
Ah perfect. I did that initially, but I was getting confused because I expected clojure
to automatically call my -main
function. But I see now that it was working fine. Thanks for the help!
@jeff.terrell I came up with it.
Nice trick! Thanks again.
I added a PR for a FAQ entry about this on http://clojure.com: https://github.com/clojure/clojure-site/pull/270
OK, followup question: how do I access command-line arguments to a #!/usr/bin/env clojure
standalone script?
@jeff.terrell They will be in *command-line-args*
That's it. Thanks!
@jeff.terrell If useful, some similar material to your FAQ is at http://planck-repl.org/dependencies.html under Shebang Deps