Drafter.Prompt.Select (drafter v0.6.0)

Copy Markdown View Source

The component behind Drafter.Prompt.select/3, multiselect/3 and search/3: a list to pick one or several entries from.

Options

  • :label - the question
  • :choices - the entries, each anything Drafter.Prompt.Choice.new/1 accepts
  • :source - (query -> choices), called with the typed text on every change, in place of :choices
  • :multiple - true picks several entries and returns their values as a list
  • :filter - true narrows the list to the entries containing the typed text, ignoring case. Always on with :source
  • :default - the value highlighted first, or with :multiple the list of values picked first
  • :min and :max - with :multiple, the fewest and most entries that may be picked. Defaults 0 and no limit
  • :limit - the most entries shown at once. Default config :drafter, prompt_limit: 7

Keys

Up, Down, Ctrl+P, Ctrl+N, Page Up, Page Down, Home and End move the highlight, which skips disabled entries and wraps at either end. Enter picks. Esc clears the typed text if there is any and otherwise stops the prompt with :cancelled.

Without :filter, k and j also move. With :multiple, Tab picks or unpicks the highlighted entry and Ctrl+A all of them; without :filter, Space and a do the same.