diff --git a/server/lib/server/release.ex b/server/lib/server/release.ex new file mode 100644 index 0000000..2ea8cf7 --- /dev/null +++ b/server/lib/server/release.ex @@ -0,0 +1,18 @@ +defmodule Server.Release do + @moduledoc "Convenience functions for IEx and future release tasks." + + @doc "Create a host and print the plaintext token once." + def register_host(name) do + case Server.Hosts.create_host(name) do + {:ok, {host, token}} -> + IO.puts("Host '#{host.name}' registered (id=#{host.id}).") + IO.puts("TOKEN: #{token}") + IO.puts("Store this token NOW — it will never be shown again.") + {:ok, host, token} + + {:error, cs} -> + IO.puts("Failed to register host: #{inspect(cs.errors)}") + {:error, cs} + end + end +end