# `Drafter.Prompt.Choice`
[🔗](https://github.com/jaman/drafter/blob/v0.6.0/lib/drafter/prompt/choice.ex#L1)

One entry of a `Drafter.Prompt.select/3` or `Drafter.Prompt.multiselect/3` list.

`label` is what is shown and `value` is what the prompt returns. `hint` is extra
text shown dimmed after the label. A `disabled` choice is shown but cannot be
picked.

`new/1` accepts the shorter spellings a prompt takes:

    iex> Drafter.Prompt.Choice.new("Phoenix")
    %Drafter.Prompt.Choice{label: "Phoenix", value: "Phoenix"}

    iex> Drafter.Prompt.Choice.new(:library)
    %Drafter.Prompt.Choice{label: "library", value: :library}

    iex> Drafter.Prompt.Choice.new({"Phoenix app", :phoenix})
    %Drafter.Prompt.Choice{label: "Phoenix app", value: :phoenix}

    iex> Drafter.Prompt.Choice.new(label: "Escript", value: :escript, hint: "one file")
    %Drafter.Prompt.Choice{label: "Escript", value: :escript, hint: "one file"}

# `input`

```elixir
@type input() ::
  t()
  | String.t()
  | atom()
  | number()
  | {String.t(), term()}
  | keyword()
  | map()
```

What `new/1` accepts: a choice, a string, an atom or number, a `{label, value}`
pair, or a keyword list or map with `:label` and optionally `:value`, `:hint` and
`:disabled`. A missing `:value` is the label.

# `t`

```elixir
@type t() :: %Drafter.Prompt.Choice{
  disabled: boolean(),
  hint: String.t() | nil,
  label: String.t(),
  value: term()
}
```

# `new`

```elixir
@spec new(input()) :: t()
```

Build a choice from any of the spellings in `t:input/0`.

---

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