From 8c49dd71d29359447c24b1cd4f48a8faf0c4fdca Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 15 Oct 2018 12:18:05 +0200 Subject: Refactor shard starting/stopping --- shard/lib/cli/cli.ex | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'shard/lib/cli') diff --git a/shard/lib/cli/cli.ex b/shard/lib/cli/cli.ex index 4f17aeb..d454a0b 100644 --- a/shard/lib/cli/cli.ex +++ b/shard/lib/cli/cli.ex @@ -8,8 +8,12 @@ defmodule SCLI do end def run() do - for {_chid, %SApp.Chat.Manifest{}, chpid} <- Shard.Manager.list_shards do - SApp.Chat.subscribe(chpid) + for {_chid, manifest, _} <- Shard.Manager.list_shards do + case manifest do + %SApp.Chat.Manifest{} -> + SApp.Chat.subscribe(Shard.Manager.find_or_start manifest) + _ -> nil + end end pk = Shard.Keys.get_any_identity @@ -92,7 +96,7 @@ defmodule SCLI do defp handle_command(state, ["list"]) do IO.puts "List of known channels:" - for {_chid, %SApp.Chat.Manifest{channel: chan}, _chpid} <- Shard.Manager.list_shards do + for {_chid, %SApp.Chat.Manifest{channel: chan}, _} <- Shard.Manager.list_shards do IO.puts "##{chan}" end state @@ -120,9 +124,8 @@ defmodule SCLI do end defp handle_command(state, ["pm" | people_list]) do - known_people = for {_, %SApp.Identity.Manifest{pk: pk}, pid} <- Shard.Manager.list_shards() do - info = SApp.Identity.get_info(pid) - {pk, info.nick} + known_people = for {_, %SApp.Identity.Manifest{pk: pk}, _} <- Shard.Manager.list_shards() do + {pk, SApp.Identity.get_nick(pk)} end pk_list = for qname <- people_list do candidates = for {pk, nick} <- known_people, -- cgit v1.2.3