Module: Doing::PromptInput

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

Overview

Methods for requesting user text input

Instance Method Summary collapse

Instance Method Details

#enter_text(prompt, default_response: '') ⇒ String

Deprecated.

Use #read_line instead

Request single-line input

Parameters:

  • prompt (String)

    The prompt

  • default_response (String) (defaults to: '')

    The default response returned if :default_answer is true

Returns:

  • (String)

    The user response

#read_line(prompt: 'Enter text', completions: [], default_response: '') ⇒ String

Request single-line input using Readline. Allows for control sequences and tab completions

Parameters:

  • prompt (String) (defaults to: 'Enter text')

    The prompt

  • completions (Array) (defaults to: [])

    Array of tab completions

  • default_response (String) (defaults to: '')

    The default response returned if :default_answer is true

Returns:

  • (String)

    User input string

#read_lines(prompt: 'Enter text', completions: [], default_response: '') ⇒ String

Request multi-line input using Readline. Allows for control sequences and tab completion

Parameters:

  • prompt (String) (defaults to: 'Enter text')

    The prompt

  • completions (Array) (defaults to: [])

    Array of tab completions

  • default_response (String) (defaults to: '')

    The default response returned if :default_answer is true

Returns:

  • (String)

    Multi-line result, joined with newlines

#request_lines(prompt: 'Enter text', default_response: '') ⇒ Object

Deprecated.

Use #read_lines instead

Request multi-line input

Parameters:

  • prompt (String) (defaults to: 'Enter text')

    The prompt

  • default_response (String) (defaults to: '')

    The default response, returned if :default_answer is true