Module: Doing::PromptChoose

Included in:
Prompt
Defined in:
lib/doing/prompt/choose.rb

Overview

Methods for creating interactive menus of options and items

Instance Method Summary collapse

Instance Method Details

#choose_from(options, prompt: 'Make a selection: ', multiple: false, sorted: true, fzf_args: []) ⇒ String

Generate a menu of options and allow user selection

Parameters:

  • options (Array) —

    The options from which to choose

  • prompt (String) (defaults to: 'Make a selection: ') —

    The prompt

  • multiple (Boolean) (defaults to: false) —

    If true, allow multiple selections

  • sorted (Boolean) (defaults to: true) —

    If true, sort selections alphanumerically

  • fzf_args (Array) (defaults to: []) —

    Additional fzf arguments

Returns:

  • (String) —

    The selected option

#choose_from_items(items, **opt) ⇒ Object

Create an interactive menu to select from a set of Items

Parameters:

  • items (Array) —

    list of items

  • opt —

    Additional options

Options Hash (**opt):

  • :include_section (Boolean) —

    Include section name for each item in menu

  • :header (String) —

    A custom header string

  • :prompt (String) —

    A custom prompt string

  • :query (String) —

    Initial query

  • :show_if_single (Boolean) —

    Show menu even if there's only one option

  • :menu (Boolean) —

    Show menu

  • :sort (Boolean) —

    Sort options

  • :multiple (Boolean) —

    Allow multiple selections

  • :case (Symbol) — default: :sensitive, :ignore, :smart