Skip to content

Commit

Permalink
Merge pull request #250 from nappex/remove-redundant-usage_msg
Browse files Browse the repository at this point in the history
Remove redundant call of usage message
  • Loading branch information
Glutexo authored Dec 17, 2024
2 parents ded9aa9 + a4935d3 commit c0a743a
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions lib/cli.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,16 @@ defmodule Onigumo.CLI do
}

def main(argv) do
case OptionParser.parse(
argv,
aliases: [C: :working_dir],
strict: [working_dir: :string]
) do
{switches, [component], []} ->
with {:ok, module} <- Map.fetch(@components, String.to_atom(component)) do
working_dir = Keyword.get(switches, :working_dir, File.cwd!())
module.main(working_dir)
else
:error -> usage_message()
end
parsed = OptionParser.parse(argv, aliases: [C: :working_dir], strict: [working_dir: :string])

_ ->
usage_message()
with {switches, [component], []} <- parsed,
{:ok, module} <- Map.fetch(@components, String.to_atom(component)) do
working_dir = Keyword.get(switches, :working_dir, File.cwd!())
module.main(working_dir)
else
{_, _, [_ | _]} -> usage_message()
{_, argv, _} when length(argv) != 1 -> usage_message()
:error -> usage_message()
end
end

Expand Down

0 comments on commit c0a743a

Please sign in to comment.