mobilizon.chapril.org-mobil.../lib/mix/tasks/mobilizon/actors/show.ex
Thomas Citharel 5e9c91e659
Added mix commands to manage users and view actors
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2019-11-21 15:51:13 +01:00

35 lines
967 B
Elixir

defmodule Mix.Tasks.Mobilizon.Actors.Show do
@moduledoc """
Task to display an actor details
"""
use Mix.Task
alias Mobilizon.Actors
alias Mobilizon.Actors.Actor
@shortdoc "Show a Mobilizon user details"
@impl Mix.Task
def run([preferred_username]) do
Mix.Task.run("app.start")
case {:actor, Actors.get_actor_by_name_with_preload(preferred_username)} do
{:actor, %Actor{} = actor} ->
Mix.shell().info("""
Informations for the actor #{actor.preferred_username}:
- Type: #{actor.type}
- Domain: #{if is_nil(actor.domain), do: "Local", else: actor.domain}
- Name: #{actor.name}
- Summary: #{actor.summary}
- User: #{if is_nil(actor.user), do: "Remote", else: actor.user.email}
""")
{:actor, nil} ->
Mix.raise("Error: No such actor")
end
end
def run(_) do
Mix.raise("mobilizon.actors.show requires an username as argument")
end
end