# `Alaja.Printer.Interactive`
[🔗](https://github.com/Lorenzo-SF/alaja/blob/2.1.0/lib/alaja/printer/interactive.ex#L1)

Interactive user-input functions for terminal CLI applications.

Provides prompts for questions, yes/no confirmation, predefined-option
selection, and bullet-list menus.

## Usage

    answer = Alaja.Printer.Interactive.question("What's your name?")
    :yes  = Alaja.Printer.Interactive.yesno("Continue?")
    Alaja.Printer.Interactive.menu("Select option:", [{"A", :a}, {"B", :b}])

# `menu`

```elixir
@spec menu(String.t(), list(), keyword()) :: :ok
```

Shows an options menu.

Displays a list of options with bullets.

## Options

- `:color` - Text color (default: :white)
- `:align` - Text alignment (default: :left)
- `:header` - Optional header text

## Examples

    iex> menu("Select an option:", [{"Start", :start}, {"Exit", :exit}])
    :ok

# `question`

```elixir
@spec question(
  String.t(),
  keyword()
) :: String.t()
```

Asks a question to the user and returns their answer.

## Options

- `:color` - Text color (default: :white)
- `:align` - Text alignment (default: :left)

## Examples

    iex> question("What is your name?")
    "John"

    iex> question("Enter value:", color: :cyan)
    "42"

# `question_with_options`

```elixir
@spec question_with_options(String.t(), list(), keyword()) :: any() | :error
```

Question with predefined options.

The options list can take three shapes:

  1. `[{label, value}, ...]` with string labels — the user types
     the label (or a prefix of it, case-insensitive).
  2. `[{label, value}, ...]` where value is an atom — the user can
     type the atom name (e.g. `:llm` → `llm`).
  3. A 1-based index (`1`, `2`, `3`) typed by the user.

Before reading the answer, the function lists the options under the
prompt so the user always knows what they can type. The `:default`
option chooses a pre-selected index that gets used if the user
just presses Enter.

Returns the `value` for the selected option, or `:error` if the
input does not match anything.

## Examples

    iex> question_with_options("Choose:", [{"Yes", :yes}, {"No", :no}])
    :yes

    iex> question_with_options("Continue?", [{"Y", :yes}, {"N", :no}], default: 1)
    :yes

# `yesno`

```elixir
@spec yesno(
  String.t(),
  keyword()
) :: :yes | :no
```

Yes or no question.

Returns `:yes` or `:no`.

Accepts `y`, `yes`, `n`, `no`, plus the index `1` for yes and `2`
for no. The `:default` option (`:yes` or `:no`) is used when the
user just presses Enter.

## Examples

    iex> yesno("Do you want to continue?")
    :yes

    iex> yesno("Are you sure?", default: :yes)
    :yes

---

*Consult [api-reference.md](api-reference.md) for complete listing*
