aboutsummaryrefslogtreecommitdiff
path: root/shard/lib/cli
diff options
context:
space:
mode:
Diffstat (limited to 'shard/lib/cli')
-rw-r--r--shard/lib/cli/cli.ex21
1 files changed, 20 insertions, 1 deletions
diff --git a/shard/lib/cli/cli.ex b/shard/lib/cli/cli.ex
index 54b882f..8495b93 100644
--- a/shard/lib/cli/cli.ex
+++ b/shard/lib/cli/cli.ex
@@ -1,12 +1,23 @@
defmodule SCLI do
@moduledoc """
- Small command line interface for the chat application
+ Small command line interface for the chat application. Supports public chat rooms,
+ private conversations, sending files (but not receiving them - could be done easily).
+
+ The code of this module is intended as an example of how to use the Shard library.
+
+ TODO: more commands.
"""
defmodule State do
+ @moduledoc"""
+ Internal state struct of the CLI.
+ """
defstruct [:room_pid, :id_pid, :pk]
end
+ @doc"""
+ Call this from the iex prompt to launch the CLI.
+ """
def run() do
for {_chid, manifest, _} <- Shard.Manager.list_shards do
case manifest do
@@ -197,6 +208,14 @@ defmodule SCLI do
state
end
+ defp handle_command(state, ["shards"]) do
+ Shard.Manager.list_shards
+ |> Enum.map(&(ShardURI.from_manifest(elem(&1, 1))))
+ |> Enum.sort()
+ |> Enum.map(&IO.puts/1)
+ state
+ end
+
defp handle_command(state, _cmd) do
IO.puts "Invalid command"
state