aboutsummaryrefslogtreecommitdiff
path: root/lib/cli/cli.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cli/cli.ex')
-rw-r--r--lib/cli/cli.ex14
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