From: Alexander Goussas Date: Mon, 2 Feb 2026 03:34:36 +0000 (-0500) Subject: feat: fetch port from command lines args X-Git-Url: http://git.frustrated-labs.net/?a=commitdiff_plain;h=448a578d0199eba68d31bf4ce36a89a878d36a30;p=dns-phrasex.git feat: fetch port from command lines args --- diff --git a/lib/dns_phrases/application.ex b/lib/dns_phrases/application.ex index 7e36f2a..5b0c4ee 100644 --- a/lib/dns_phrases/application.ex +++ b/lib/dns_phrases/application.ex @@ -7,14 +7,14 @@ defmodule DnsPhrases.Application do @impl true def start(_type, _args) do + opts = [port: :integer] + {parsed, _, _} = OptionParser.parse(System.argv(), strict: opts) + children = [ - # TODO: Fetch the port from command line - {DnsPhrases.Server, [listen_port: 3069]}, - {Postgrex, [name: :db]} + {Postgrex, [name: :db]}, + {DnsPhrases.Server, [listen_port: parsed[:port]]} ] - # See https://hexdocs.pm/elixir/Supervisor.html - # for other strategies and supported options opts = [strategy: :one_for_one, name: DnsPhrases.Supervisor] Supervisor.start_link(children, opts) end