Skip to content

Instantly share code, notes, and snippets.

@vortec
Created February 25, 2017 22:16
Show Gist options
  • Save vortec/190f6a7fe0c9fe4c4a661227c4aab19e to your computer and use it in GitHub Desktop.
Save vortec/190f6a7fe0c9fe4c4a661227c4aab19e to your computer and use it in GitHub Desktop.
defmodule KVServer.Command do
@doc ~S"""
Parses a line into a command.
## Examples
iex> KVServer.Command.parse "CREATE shopping\r\n"
{:ok, {:create, "shopping"}}
"""
def parse(line) do
case String.split(line) do
["CREATE", bucket] -> {:ok, {:create, bucket}}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment