class Term::Prompt
- Term::Prompt
- Reference
- Object
Defined in:
prompt/answers_collector.crprompt/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
-
#ask(message = "", **options, &block : Question -> )
Ask a question.
-
#ask(message = "", **options)
ditto
- #clear_line(*args, **options)
- #clear_line(*args, **options, &)
- #clear_lines(*args, **options)
- #clear_lines(*args, **options, &)
-
#collect(**options, &block : AnswersCollector -> )
Gathers more than one answer
- #count_screen_lines(*args, **options)
- #count_screen_lines(*args, **options, &)
- #cursor : Term::Cursor.class
-
#debug(*messages)
Print debug information in terminal top right corner.
-
#decorate(message, color = @enabled_color)
Decorare the provided
message
using the givencolor
. -
#enum_select(question, choices = nil, **options, &block : EnumList -> )
Ask a question with indexed list
-
#enum_select(question, choices = nil, **options)
ditto
- #env : Hash(String, String)
- #env=(env : Hash(String, String))
-
#error(*args, **options)
Print statement(s) out using the palette error color.
-
#expand(question, choices = nil, **options, &block : Expander -> )
Expand available options
-
#expand(question, choices = nil, **options)
ditto
- #flush(*args, **options)
- #flush(*args, **options, &)
- #hide(*args, **options)
- #hide(*args, **options, &)
- #input : IO::FileDescriptor
- #input=(input : IO::FileDescriptor)
- #interrupt : Symbol
- #interrupt=(interrupt : Symbol)
-
#keypress(message = "", **options, &block : Keypress -> )
Ask a question with a keypress answer.
-
#keypress(message = "", **options)
ditto
-
#mask(message = "", **options, &block : MaskQuestion -> )
Ask a masked question.
-
#mask(message = "", **options)
ditto
-
#multi_select(question, choices = nil, **options, &block : List -> )
Ask a question with multiple attributes activated
-
#multi_select(question, choices = nil, **options)
Ask a question with multiple attributes activated
-
#multiline(message = "", **options, &block : Multiline -> )
Ask a question with a multiline answer
-
#multiline(message = "", **options)
ditto
-
#no?(message = "", **options, &block : ConfirmQuestion -> )
Ask a yes or no question, with "no" being the default answer.
-
#no?(message = "", **options)
ditto
-
#ok(*args, **options)
Print statement(s) out using the palette active color.
- #output : IO::FileDescriptor
- #output=(output : IO::FileDescriptor)
- #palette : Palette
- #palette=(palette : Palette)
- #prefix : String
- #prefix=(prefix : String)
- #print(*args, **options)
- #print(*args, **options, &)
- #puts(*args, **options)
- #puts(*args, **options, &)
- #read_char(*args, **options)
- #read_char(*args, **options, &)
- #read_keypress(*args, **options)
- #read_keypress(*args, **options, &)
- #read_line(*args, **options)
- #read_line(*args, **options, &)
- #read_multiline(*args, **options)
- #read_multiline(*args, **options, &)
- #reader : Term::Reader
-
#say(message = "", **options)
Print statement out.
-
#select(question, choices = nil, **options, &block : List -> )
Ask a question with a list of options
-
#select(question, choices = nil, **options)
Ask a question with a list of options
- #show(*args, **options)
- #show(*args, **options, &)
-
#slider(question, **options, &block : Slider -> )
Ask a question with a range slider
-
#slider(question, **options)
ditto
-
#symbols(new_symbols = nil)
Change symbols used by this prompt
- #track_history : Bool
- #track_history=(track_history : Bool)
- #trigger(*args, **options)
- #trigger(*args, **options, &)
-
#warn(*args, **options)
Print statement(s) out using the palette warning color.
-
#yes?(message = "", **options, &block : ConfirmQuestion -> )
Ask a yes or no question, with "yes" being the default answer.
-
#yes?(message = "", **options)
ditto
Constructor Detail
Instance Method Detail
Ask a question.
Example:
prompt.ask("What is your name?")
Gathers more than one answer
Example:
prompt.collect do
key(:name).ask("Name?")
key(:age).ask("Age?")
end
Decorare the provided message
using the given color
. Color can be
a symbol, a Cor
instance, or an {R, G, B}
tuple.
Ask a question with indexed list
Example:
editors = %w(emacs nano vim)
prompt.enum_select("Select editor:", editors)
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)
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])
Ask a masked question. Masked questions replace each input character with a mask value.
Example:
prompt.mask("Please enter your password:")
Ask a question with multiple attributes activated
Example:
prompt.multi_select("What sizes?") do |menu|
menu.choice :large
menu.choices %w(:medium :small)
end
Ask a question with multiple attributes activated
Example:
choices = %w(Scorpion Jax Kitana Baraka Jade)
prompt.multi_select("Choose your destiny?", choices)
Ask a question with a multiline answer
Example:
prompt.multiline("Description?")
Ask a yes or no question, with "no" being the default answer.
Example:
prompt.no?("Would you like to continue?")
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)
Ask a question with a list of options
Example:
prompt.select("What size?") do |menu|
menu.choice :large
menu.choices %w(:medium :small)
end
Ask a question with a list of options
Example:
prompt.select("What size?", %w(large medium small))
Ask a question with a range slider
Example:
prompt.slider("What size?", min: 32, max: 54, step: 2)
Ask a yes or no question, with "yes" being the default answer.
Example:
prompt.yes?("Would you like to continue?")