chore(server): iex helper for host registration
This commit is contained in:
parent
61595e0293
commit
9e55eae6a1
1 changed files with 18 additions and 0 deletions
18
server/lib/server/release.ex
Normal file
18
server/lib/server/release.ex
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue