- IPrintWithWriter protocol + CljElixir.Printer module with pr-str, print-str, pr, prn for all BEAM types (EDN-like output) - Source-mapped error messages: line/col metadata from reader now propagated through transformer into Elixir AST for accurate error locations in .clje files - Interactive REPL (mix clje.repl) with multi-line input detection, history, bindings persistence, and pr-str formatted output - nREPL server (mix clje.nrepl) with TCP transport, Bencode wire protocol, session management, and core operations (clone, close, eval, describe, ls-sessions, load-file, interrupt, completions). Writes .nrepl-port for editor auto-discovery. 92 new tests (699 total, 0 failures). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
37 lines
923 B
Elixir
37 lines
923 B
Elixir
defmodule Mix.Tasks.Clje.Nrepl do
|
|
@moduledoc """
|
|
Starts an nREPL server for CljElixir.
|
|
|
|
## Usage
|
|
|
|
mix clje.nrepl # random port
|
|
mix clje.nrepl --port 7888 # specific port
|
|
|
|
Writes port to `.nrepl-port` file for editor auto-discovery.
|
|
"""
|
|
|
|
use Mix.Task
|
|
|
|
@shortdoc "Start a CljElixir nREPL server"
|
|
|
|
@impl Mix.Task
|
|
def run(args) do
|
|
{opts, _, _} = OptionParser.parse(args, strict: [port: :integer])
|
|
port = Keyword.get(opts, :port, 0)
|
|
|
|
Mix.Task.run("compile")
|
|
Mix.Task.run("app.start")
|
|
|
|
{:ok, server} = CljElixir.NRepl.Server.start_link(port: port)
|
|
actual_port = CljElixir.NRepl.Server.port(server)
|
|
|
|
File.write!(".nrepl-port", Integer.to_string(actual_port))
|
|
|
|
IO.puts("nREPL server started on port #{actual_port} on host 127.0.0.1")
|
|
IO.puts("Port written to .nrepl-port")
|
|
IO.puts("Press Ctrl+C to stop\n")
|
|
|
|
Process.sleep(:infinity)
|
|
end
|
|
end
|