I tried using fzf, a command-line fuzzy finder, within my Elixir script. Here's the code I used:
defmodule FzfExample do
def select_from_list(list) do
{selected, 0} = System.cmd("fzf", [], input: Enum.join(list, "\n"))
String.trim(selected)
end
end
IO.puts("Select an item:")
items = ["apple", "banana", "cherry", "date"]
selected_item = FzfExample.select_from_list(items)
IO.puts("You selected: #{selected_item}")
However, when I run the script, I get this error:
Select an item: ** (ArgumentError) invalid option :input with value "apple\nbanana\ncherry\ndate" (elixir 1.15.4) lib/system.ex:1175: System.cmd_opts/4 (elixir 1.15.4) lib/system.ex:1100: System.do_cmd/3
fzf.exs:4: FzfExample.select_from_list/1
fzf.exs:11: (file)