Fix Quartz port not being passed correctly

When CLI options --port/--ws-port were not provided, nil values were
being explicitly passed to Server.start_link, which caused Keyword.get
to return nil instead of the default. Now we only include port options
in the keyword list if they have actual values.
This commit is contained in:
Ignacio Ballesteros
2026-02-21 21:50:13 +01:00
parent 87fd311005
commit 11ab8336e4
2 changed files with 1147 additions and 7 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -75,13 +75,16 @@ defmodule OrgGarden.CLI do
IO.puts("==> Starting development server...")
case OrgGarden.Server.start_link(
server_opts =
[
notes_dir: notes_dir,
output_dir: output_dir,
content_dir: content_dir,
port: opts[:port],
ws_port: opts[:ws_port]
) do
content_dir: content_dir
]
|> maybe_put(:port, opts[:port])
|> maybe_put(:ws_port, opts[:ws_port])
case OrgGarden.Server.start_link(server_opts) do
{:ok, pid} ->
IO.puts("==> Server running at http://localhost:#{opts[:port] || Config.get(:http_port, 8080)}")
IO.puts("==> Watching #{notes_dir} for changes (Ctrl+C to stop)")
@@ -379,4 +382,7 @@ defmodule OrgGarden.CLI do
IO.puts(:stderr, message)
System.halt(1)
end
defp maybe_put(keyword, _key, nil), do: keyword
defp maybe_put(keyword, key, value), do: Keyword.put(keyword, key, value)
end