Refactor func names

This commit is contained in:
Harshad Sharma 2024-05-19 07:26:44 +05:30
parent 4f90ccb047
commit d6b2522fdc

View file

@ -14,7 +14,7 @@ defmodule Freedive.Api.Service.Cli do
enabled_service_names = enabled_service_names()
all_service_names
|> Enum.map(fn name -> service_details(name, Enum.member?(enabled_service_names, name)) end)
|> Enum.map(fn name -> service_details!(name, Enum.member?(enabled_service_names, name)) end)
|> Enum.into(%{}, &{&1[:name], &1})
end
@ -56,7 +56,7 @@ defmodule Freedive.Api.Service.Cli do
end
end
def service_details(name, enabled \\ nil) do
def service_details!(name, enabled \\ nil) do
enabled = if(enabled != nil, do: enabled, else: service_is_enabled?(name))
%{
@ -71,7 +71,7 @@ defmodule Freedive.Api.Service.Cli do
}
end
def refresh(service) do
def refresh_service!(service) do
name = service.name
%{
@ -134,11 +134,11 @@ defmodule Freedive.Api.Service.Cli do
defp service(name, command, args) do
case execute(@service_bin, [name, command] ++ args, doas: true) do
{:ok, stdout} ->
# Logger.debug("service, log: #{inspect(stdout)}")
Logger.debug("service #{name} #{command} #{args}: #{inspect(stdout)}")
{:ok, stdout}
{:error, {stderr, code}} ->
# Logger.warning("service #{name} #{command}: #{String.trim(stderr)}")
Logger.debug("service #{name} #{command} #{args}: (#{code}) #{String.trim(stderr)}")
{:error, {stderr, code}}
end
end