Current section
Files
Jump to
Current section
Files
lib/jacob/command/helper.ex
defmodule Jacob.Command.Helper do
@moduledoc """
Povides various functions related to `Jacob.Command`
"""
@doc """
Return the command's id for the given command name or module
"""
@spec id(String.t() | module) :: atom
def id(command) when is_binary(command) do
command |> name_to_id()
end
def id(command) when is_atom(command) do
command.name() |> name_to_id()
end
defp name_to_id(nil), do: nil
defp name_to_id(name) do
name
|> String.downcase()
|> String.to_atom()
end
end