Make issues more elixir-y
This commit is contained in:
parent
3f17b025a9
commit
9423d7ea71
|
@ -18,24 +18,24 @@ defmodule Issues.CLI do
|
|||
Return a tuple of `{ user, project, count }`, or `:help` if help was given
|
||||
"""
|
||||
def parse_args(argv) do
|
||||
parse =
|
||||
OptionParser.parse(argv,
|
||||
switches: [help: :boolean],
|
||||
aliases: [h: :help]
|
||||
)
|
||||
OptionParser.parse(argv,
|
||||
switches: [help: :boolean],
|
||||
aliases: [h: :help]
|
||||
)
|
||||
|> elem(1)
|
||||
|> args_to_internal_representation
|
||||
|
||||
case parse do
|
||||
{[help: true], _, _} ->
|
||||
:help
|
||||
end
|
||||
|
||||
{_, [user, project, count], _} ->
|
||||
{user, project, String.to_integer(count)}
|
||||
def args_to_internal_representation([user, project, count]) do
|
||||
{ user, project, String.to_integer(count) }
|
||||
end
|
||||
|
||||
{_, [user, project], _} ->
|
||||
{user, project, @default_count}
|
||||
def args_to_internal_representation([user, project]) do
|
||||
{ user, project, @default_count }
|
||||
end
|
||||
|
||||
_ ->
|
||||
:help
|
||||
end
|
||||
def args_to_internal_representation(_) do # either bad arg or --help
|
||||
:help
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue