diff options
Diffstat (limited to 'shard/lib/cli')
-rw-r--r-- | shard/lib/cli/cli.ex | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/shard/lib/cli/cli.ex b/shard/lib/cli/cli.ex index d454a0b..380282d 100644 --- a/shard/lib/cli/cli.ex +++ b/shard/lib/cli/cli.ex @@ -170,6 +170,25 @@ defmodule SCLI do state end + defp handle_command(state, ["send_file", path]) do + {mime_type, 0} = System.cmd("file", ["-b", "--mime-type", path]) + mime_type = String.trim mime_type + IO.puts("Guessed mime type: #{mime_type}") + handle_command(state, ["send_file", path, mime_type]) + end + + defp handle_command(state, ["send_file", path, mime_type]) do + if state.room_pid != nil do + {:ok, m, _} = SApp.File.create(path, mime_type) + uri = ShardURI.from_manifest(m) + IO.puts("sending URI: #{uri}") + SApp.Chat.chat_send(state.room_pid, state.pk, uri) + else + IO.puts("Not in a chat room!") + end + state + end + defp handle_command(state, _cmd) do IO.puts "Invalid command" state |