Print out settings that will be removed when specifying the group and key for consistency
Fix error message when specified key doesn't exist
This commit is contained in:
parent
61494b5245
commit
93428d7c11
|
@ -134,7 +134,18 @@ def run(["delete", "--force", group, key]) do
|
||||||
group = maybe_atomize(group)
|
group = maybe_atomize(group)
|
||||||
key = maybe_atomize(key)
|
key = maybe_atomize(key)
|
||||||
|
|
||||||
|
with true <- key_exists?(group, key) do
|
||||||
|
shell_info("The following settings will be removed from ConfigDB:\n")
|
||||||
|
|
||||||
|
group
|
||||||
|
|> ConfigDB.get_by_group_and_key(key)
|
||||||
|
|> dump()
|
||||||
|
|
||||||
delete_key(group, key)
|
delete_key(group, key)
|
||||||
|
else
|
||||||
|
_ ->
|
||||||
|
shell_error("No settings in ConfigDB for #{inspect(group)}, #{inspect(key)}. Aborting.")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def run(["delete", "--force", group]) do
|
def run(["delete", "--force", group]) do
|
||||||
|
@ -157,11 +168,22 @@ def run(["delete", group, key]) do
|
||||||
group = maybe_atomize(group)
|
group = maybe_atomize(group)
|
||||||
key = maybe_atomize(key)
|
key = maybe_atomize(key)
|
||||||
|
|
||||||
|
with true <- key_exists?(group, key) do
|
||||||
|
shell_info("The following settings will be removed from ConfigDB:\n")
|
||||||
|
|
||||||
|
group
|
||||||
|
|> ConfigDB.get_by_group_and_key(key)
|
||||||
|
|> dump()
|
||||||
|
|
||||||
if shell_prompt("Are you sure you want to continue?", "n") in ~w(Yn Y y) do
|
if shell_prompt("Are you sure you want to continue?", "n") in ~w(Yn Y y) do
|
||||||
delete_key(group, key)
|
delete_key(group, key)
|
||||||
else
|
else
|
||||||
shell_error("No changes made.")
|
shell_error("No changes made.")
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
_ ->
|
||||||
|
shell_error("No settings in ConfigDB for #{inspect(group)}, #{inspect(key)}. Aborting.")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def run(["delete", group]) do
|
def run(["delete", group]) do
|
||||||
|
@ -315,6 +337,13 @@ defp group_exists?(group) do
|
||||||
|> Enum.any?()
|
|> Enum.any?()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp key_exists?(group, key) do
|
||||||
|
group
|
||||||
|
|> ConfigDB.get_by_group_and_key(key)
|
||||||
|
|> is_nil
|
||||||
|
|> Kernel.!()
|
||||||
|
end
|
||||||
|
|
||||||
defp maybe_atomize(arg) when is_atom(arg), do: arg
|
defp maybe_atomize(arg) when is_atom(arg), do: arg
|
||||||
|
|
||||||
defp maybe_atomize(":" <> arg), do: maybe_atomize(arg)
|
defp maybe_atomize(":" <> arg), do: maybe_atomize(arg)
|
||||||
|
|
Loading…
Reference in New Issue