class Term::Prompt

Defined in:

prompt/answers_collector.cr
prompt/block_paginator.cr
prompt/choice.cr
prompt/choices.cr
prompt/confirm_question.cr
prompt/enum_list.cr
prompt/expander.cr
prompt/keypress.cr
prompt/list.cr
prompt/mask_question.cr
prompt/multi_list.cr
prompt/multiline.cr
prompt/paginator.cr
prompt/palette.cr
prompt/question.cr
prompt/question/validators.cr
prompt/result.cr
prompt/slider.cr
prompt/statement.cr
prompt/symbols.cr
prompt/validator.cr
term-prompt.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(**options) #

[View source]

Instance Method Detail

def ask(message = "", **options, &block : Question -> ) #

Ask a question.

Example:

prompt.ask("What is your name?")

[View source]
def ask(message = "", **options) #

ditto


[View source]
def clear_line(*args, **options) #

[View source]
def clear_line(*args, **options, &) #

[View source]
def clear_lines(*args, **options) #

[View source]
def clear_lines(*args, **options, &) #

[View source]
def collect(**options, &block : AnswersCollector -> ) #

Gathers more than one aswer

Example:

prompt.collect do
  key(:name).ask("Name?")
  key(:age).ask("Age?")
end

[View source]
def count_screen_lines(*args, **options) #

[View source]
def count_screen_lines(*args, **options, &) #

[View source]
def cursor : Term::Cursor.class #

[View source]
def debug(*messages) #

Print debug information in terminal top right corner.


[View source]
def decorate(message, color = @enabled_color) #

Decorare the provided message using the given color. Color can be a symbol, a Cor instance, or an {R, G, B} tuple.


[View source]
def enum_select(question, choices = nil, **options, &block : EnumList -> ) #

Ask a question with indexed list

Example:

editors = %w(emacs nano vim)
prompt.enum_select("Select editor:", editors)

[View source]
def enum_select(question, choices = nil, **options) #

ditto


[View source]
def env : Hash(String, String) #

[View source]
def env=(env : Hash(String, String)) #

[View source]
def error(*args, **options) #

Print statement(s) out using the palette error color.


[View source]
def expand(question, choices = nil, **options, &block : Expander -> ) #

Expand available options

Example:

prompt = Term::Prompt.new

choices = [{
  key: "Y",
  name: "Overwrite",
  value: :yes
}, {
  key: "n",
  name: "Skip",
  value: :no
}]

prompt.expand("Overwrite shard.yml?", choices)

[View source]
def expand(question, choices = nil, **options) #

ditto


[View source]
def flush(*args, **options) #

[View source]
def flush(*args, **options, &) #

[View source]
def hide(*args, **options) #

[View source]
def hide(*args, **options, &) #

[View source]
def input : IO::FileDescriptor #

[View source]
def input=(input : IO::FileDescriptor) #

[View source]
def interrupt : Symbol #

[View source]
def interrupt=(interrupt : Symbol) #

[View source]
def keypress(message = "", **options, &block : Keypress -> ) #

Ask a question with a keypress answer.

Example:

prompt.keypress("Press any key to continue")
# or
prompt.keypress("Press Ctrl+D to continue", keys: [:ctrl_d])

[View source]
def keypress(message = "", **options) #

ditto


[View source]
def mask(message = "", **options, &block : MaskQuestion -> ) #

Ask a masked question. Masked questions replace each input character with a mask value.

Example:

prompt.mask("Please enter your password:")

[View source]
def mask(message = "", **options) #

ditto


[View source]
def multi_select(question, choices = nil, **options, &block : List -> ) #

Ask a question with multiple attributes activated

Example:

prompt.multi_select("What sizes?") do |menu|
  menu.choice :large
  menu.choices %w(:medium :small)
end

[View source]
def multi_select(question, choices = nil, **options) #

Ask a question with multiple attributes activated

Example:

choices = %w(Scorpion Jax Kitana Baraka Jade)
prompt.multi_select("Choose your destiny?", choices)

[View source]
def multiline(message = "", **options, &block : Multiline -> ) #

Ask a question with a multiline answer

Example:

prompt.multiline("Description?")

[View source]
def multiline(message = "", **options) #

ditto


[View source]
def no?(message = "", **options, &block : ConfirmQuestion -> ) #

Ask a yes or no question, with "no" being the default answer.

Example:

prompt.no?("Would you like to continue?")

[View source]
def no?(message = "", **options) #

ditto


[View source]
def ok(*args, **options) #

Print statement(s) out using the palette active color.


[View source]
def output : IO::FileDescriptor #

[View source]
def output=(output : IO::FileDescriptor) #

[View source]
def palette : Palette #

[View source]
def palette=(palette : Palette) #

[View source]
def prefix : String #

[View source]
def prefix=(prefix : String) #

[View source]
def print(*args, **options) #

[View source]
def print(*args, **options, &) #

[View source]
def puts(*args, **options) #

[View source]
def puts(*args, **options, &) #

[View source]
def read_char(*args, **options) #

[View source]
def read_char(*args, **options, &) #

[View source]
def read_keypress(*args, **options) #

[View source]
def read_keypress(*args, **options, &) #

[View source]
def read_line(*args, **options) #

[View source]
def read_line(*args, **options, &) #

[View source]
def read_multiline(*args, **options) #

[View source]
def read_multiline(*args, **options, &) #

[View source]
def reader : Term::Reader #

[View source]
def say(message = "", **options) #

Print statement out. If the supplied message ends with a space or tab character, a new line will not be appended.

Example

prompt.say("Simple things.", color: :red)

[View source]
def select(question, choices = nil, **options, &block : List -> ) #

Ask a question with a list of options

Example:

prompt.select("What size?") do |menu|
  menu.choice :large
  menu.choices %w(:medium :small)
end

[View source]
def select(question, choices = nil, **options) #

Ask a question with a list of options

Example:

prompt.select("What size?", %w(large medium small))

[View source]
def show(*args, **options) #

[View source]
def show(*args, **options, &) #

[View source]
def slider(question, **options, &block : Slider -> ) #

Ask a question with a range slider

Example:

prompt.slider("What size?", min: 32, max: 54, step: 2)

[View source]
def slider(question, **options) #

ditto


[View source]
def symbols(new_symbols = nil) #

Change symbols used by this prompt


[View source]
def track_history : Bool #

[View source]
def track_history=(track_history : Bool) #

[View source]
def trigger(*args, **options) #

[View source]
def trigger(*args, **options, &) #

[View source]
def warn(*args, **options) #

Print statement(s) out using the palette warning color.


[View source]
def yes?(message = "", **options, &block : ConfirmQuestion -> ) #

Ask a yes or no question, with "yes" being the default answer.

Example:

prompt.yes?("Would you like to continue?")

[View source]
def yes?(message = "", **options) #

ditto


[View source]