diff options
Diffstat (limited to 'shard/lib/cli')
-rw-r--r-- | shard/lib/cli/cli.ex | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/shard/lib/cli/cli.ex b/shard/lib/cli/cli.ex index c3afe8f..bf3a555 100644 --- a/shard/lib/cli/cli.ex +++ b/shard/lib/cli/cli.ex @@ -4,6 +4,10 @@ defmodule SCLI do """ def run() do + for {_chid, _manifest, chpid} <- Shard.Manager.list_shards do + GenServer.cast(chpid, {:subscribe, self()}) + end + run(nil) end @@ -64,11 +68,15 @@ defmodule SCLI do end defp handle_command(pid, ["hist"]) do - GenServer.call(pid, {:read_history, nil, 25}) - |> Enum.each(fn {{ts, nick, msg}, true} -> - IO.puts "#{ts |> DateTime.from_unix! |> DateTime.to_iso8601} <#{nick}> #{msg}" - end) - pid + if pid == nil do + IO.puts "Not currently on a channel!" + else + GenServer.call(pid, {:read_history, nil, 25}) + |> Enum.each(fn {{ts, nick, msg}, true} -> + IO.puts "#{ts |> DateTime.from_unix! |> DateTime.to_iso8601} <#{nick}> #{msg}" + end) + pid + end end defp handle_command(_pid, ["join", qchan]) do |