@@ -138,7 +138,7 @@ def py_dict_to_keyword_map(py_dict):
138
138
return hash_map
139
139
140
140
141
- def init_clojure_repl (** kw_args ):
141
+ def init_jvm (** kw_args ):
142
142
"""Initialize clojure with extra arguments specifically for embedding a cider-nrepl
143
143
server. Then start an nrepl server. The port will both be printed to stdout and
144
144
output to a .nrepl_server file. This function does not return as it leaves the GIL
@@ -157,10 +157,36 @@ def init_clojure_repl(**kw_args):
157
157
bind=\" 0.0.0.0\" """
158
158
javabridge .start_vm (run_headless = True , class_path = repl_classpath (** kw_args ))
159
159
init_clojure_runtime ()
160
+ if "load_user_clj" in kw_args :
161
+ resolve_call_fn ("clojure.core/load-file" ,
162
+ "user.clj" )
160
163
init_libpy_embedded ()
161
- resolve_call_fn ("libpython-clj2.embedded/start-repl!" ,
162
- py_dict_to_keyword_map (kw_args ))
163
164
165
+ if "start_repl" in kw_args :
166
+ resolve_call_fn ("libpython-clj2.embedded/start-repl!" ,
167
+ py_dict_to_keyword_map (kw_args ))
168
+
169
+ if "kill_vm_after" in kw_args :
170
+ javabridge .kill_vm ()
171
+
172
+ def load_clojure_file (** kw_args ):
173
+ """Initializes clojure and loads and runs a Clojure file. This function load the specified clojure file
174
+ and kills then the jvm and returns.
175
+
176
+ Keyword arguments are:
177
+
178
+ * `classpath_args` - List of additional arguments that be passed to the clojure
179
+ process when building the classpath.
180
+ * `clj_file` Clojure file to be loaded with Clojure `load-file` fn
181
+ """
182
+ javabridge .start_vm (run_headless = True , class_path = repl_classpath (** kw_args ))
183
+ init_clojure_runtime ()
184
+ init_libpy_embedded ()
185
+ try :
186
+ resolve_call_fn ("clojure.core/load-file" ,
187
+ kw_args ["clj_file" ])
188
+ finally :
189
+ javabridge .kill_vm ()
164
190
165
191
class GenericJavaObj :
166
192
__str__ = javabridge .make_method ("toString" , "()Ljava/lang/String;" )
0 commit comments