meilisearch: show keys by name not description

This makes show-key’s output match our documentation as of Meilisearch
1.8.0-8-g4d5971f343c00d45c11ef0cfb6f61e83a8508208. Since I’m not sure
if older versions maybe only provided description, it will fallback to
the latter if no name parameter exists.
This commit is contained in:
Oneric 2024-05-15 06:46:47 +02:00
parent 65aeaefa41
commit 59685e25d2

View file

@ -126,8 +126,12 @@ def run(["show-keys", master_key]) do
decoded = Jason.decode!(result.body) decoded = Jason.decode!(result.body)
if decoded["results"] do if decoded["results"] do
Enum.each(decoded["results"], fn %{"description" => desc, "key" => key} -> Enum.each(decoded["results"], fn
IO.puts("#{desc}: #{key}") %{"name" => name, "key" => key} ->
IO.puts("#{name}: #{key}")
%{"description" => desc, "key" => key} ->
IO.puts("#{desc}: #{key}")
end) end)
else else
IO.puts("Error fetching the keys, check the master key is correct: #{inspect(decoded)}") IO.puts("Error fetching the keys, check the master key is correct: #{inspect(decoded)}")