diff options
author | Alex Auvolat <alex@adnab.me> | 2018-07-04 14:45:01 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2018-07-04 14:45:01 +0200 |
commit | d786bbd6e43d88b50085d1ecce6288a617bebbe8 (patch) | |
tree | 886ad2b2c5c9371bb5122b0be8bda56b525e2ea1 /lib/cli/cli.ex | |
parent | b234a360dafa0a65d797614aad5a4514570784f8 (diff) | |
download | shard-d786bbd6e43d88b50085d1ecce6288a617bebbe8.tar.gz shard-d786bbd6e43d88b50085d1ecce6288a617bebbe8.zip |
Document
Diffstat (limited to 'lib/cli/cli.ex')
-rw-r--r-- | lib/cli/cli.ex | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/cli/cli.ex b/lib/cli/cli.ex index 0402b3f..d2e5f6a 100644 --- a/lib/cli/cli.ex +++ b/lib/cli/cli.ex @@ -1,4 +1,8 @@ defmodule SCLI do + @moduledoc """ + Small command line interface for the chat application + """ + def run() do run(nil) end @@ -26,14 +30,14 @@ defmodule SCLI do end end - def handle_command(pid, ["connect", ipstr, portstr]) do + defp handle_command(pid, ["connect", ipstr, portstr]) do {:ok, ip} = :inet.parse_address (to_charlist ipstr) {port, _} = Integer.parse portstr SNet.Manager.add_peer(ip, port) pid end - def handle_command(pid, ["list"]) do + defp handle_command(pid, ["list"]) do IO.puts "List of known channels:" list = GenServer.call(Shard.Manager, :list) for {_chid, chpid} <- list do @@ -43,7 +47,7 @@ defmodule SCLI do pid end - def handle_command(pid, ["join", qchan]) do + defp handle_command(pid, ["join", qchan]) do list = GenServer.call(Shard.Manager, :list) list = for {_chid, chpid} <- list, {:chat, chan} = GenServer.call(chpid, :manifest), @@ -58,12 +62,12 @@ defmodule SCLI do end end - def handle_command(pid, ["nick", nick]) do + defp handle_command(pid, ["nick", nick]) do Shard.Identity.set_nickname nick pid end - def handle_command(pid, _cmd) do + defp handle_command(pid, _cmd) do IO.puts "Invalid command" pid end |