Demand
Demand is a library for creating interactive console prompts in Elixir.
It is inspired by the Rust library demand (which in turn is inspired by Go's huh).
Installation
Add demand to your list of dependencies in mix.exs:
def deps do
[
{:demand, "~> 0.1.0"}
]
endUsage
Check the examples/ directory for runnable examples.
Input
alias Demand.Input
Input.new("What's your name?")
|> Input.run()Select
alias Demand.Select
Select.new("Choose a color")
|> Select.option("Red")
|> Select.option("Blue")
|> Select.option("Green")
|> Select.run()MultiSelect
alias Demand.MultiSelect
MultiSelect.new("Choose toppings")
|> MultiSelect.option("Cheese")
|> MultiSelect.option("Pepperoni")
|> MultiSelect.option("Mushrooms")
|> MultiSelect.run()Confirm
alias Demand.Confirm
Confirm.new("Are you sure?")
|> Confirm.run()Dialog
alias Demand.Dialog
Dialog.new("Are you sure?")
|> Dialog.buttons(["Yes", "No"])
|> Dialog.run()List
alias Demand.List
List.new("Items")
|> List.item("Item 1")
|> List.item("Item 2")
|> List.run()Spinner
alias Demand.Spinner
Spinner.new("Loading...")
|> Spinner.run(fn -> :timer.sleep(1000) end)