Skip to content

Commit

Permalink
Remove redundant call of usage message
Browse files Browse the repository at this point in the history
  • Loading branch information
nappex committed Nov 9, 2024
1 parent ded9aa9 commit 2e74e16
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions lib/cli.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,14 @@ 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()
end
end

Expand Down

0 comments on commit 2e74e16

Please sign in to comment.