Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Call url-connect instead of just connect.

Accept URLs on --attach rather than just host/port.
  • Loading branch information...
commit 7181ec832fe4ba8ea2ed524d7d877c11b88312f9 1 parent dd2080a
Phil Hagelberg authored

Showing 1 changed file with 14 additions and 13 deletions. Show diff stats Hide diff stats

  1. +14 13 src/clj/reply/eval_modes/nrepl.clj
27 src/clj/reply/eval_modes/nrepl.clj
@@ -66,19 +66,20 @@
66 66 (binding [*print-meta* true]
67 67 (pr-str read-result))))))))))
68 68
69   -(defn get-connection [options]
70   - (let [attach (:attach options)
71   - [attach-port attach-host] (and attach
72   - (reverse (.split attach ":")))
73   - port (if attach-port
74   - (Integer/parseInt attach-port)
75   - (-> (nrepl.server/start-server :port (Integer/parseInt (or (:port options) "0")))
76   - deref
77   - :ss
78   - .getLocalPort))
79   - host (or attach-host
80   - (:host options "localhost"))]
81   - (nrepl/connect :host host :port port)))
  69 +;; TODO: this could be less convoluted if we could break backwards-compat
  70 +(defn- url-for [attach host port]
  71 + (if (and attach (re-find #"^\w+://" attach))
  72 + attach
  73 + (let [[port host] (if attach
  74 + (reverse (.split attach ":"))
  75 + [port host])]
  76 + (format "nrepl://%s:%s" (or host "localhost") port))))
  77 +
  78 +(defn get-connection [{:keys [attach host port]}]
  79 + (let [port (if-not attach
  80 + (-> (nrepl.server/start-server :port (Integer. (or port 0)))
  81 + deref :ss .getLocalPort))]
  82 + (nrepl/url-connect (url-for attach host port))))
82 83
83 84 (defn adhoc-eval [client session form]
84 85 (let [results (atom "nil")]

0 comments on commit 7181ec8

Please sign in to comment.
Something went wrong with that request. Please try again.