Module: Doing::Prompt

Extended by:
Color
Defined in:
lib/doing/prompt.rb

Overview

Terminal Prompt methods

Constant Summary

Constants included from Color

Color::ATTRIBUTES, Color::ATTRIBUTE_NAMES, Color::COLORED_REGEXP

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Color

attributes, coloring?, support?, uncolor

Class Attribute Details

.default_answerObject

.force_answerObject

Class 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

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

.enter_text(prompt, default_response: '') ⇒ Object

.fzfObject

.install_fzfObject

Raises:

  • (RuntimeError)

.yn(question, default_response: false) ⇒ Bool

Ask a yes or no question in the terminal

Parameters:

  • question (String)

    The question to ask

  • default_response (Bool) (defaults to: false)

    default response if no input

Returns:

  • (Bool)

    yes or no