class

Term::Prompt

Inherits Reference / Object

Constants

VERSION = {{ (`shards version /tmp/tmp.NeEjlA/src/src/prompt`).chomp.stringify }}

Constructors

Instance methods

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

Ask a question.

Example:

prompt.ask("What is your name?")
Source
ask(message = "", **options)

ditto

Source
autocomplete(question, choices = nil, **options, &block : Autocomplete -> )

Ask a question with autocomplete suggestions

Example:

frameworks = %w(Rails Django Flask Laravel Express React Vue Angular)
prompt.autocomplete("Choose a framework:", frameworks)
Source
autocomplete(question, choices = nil, **options)

ditto

Source
clear_line(*args, **options)
Source
clear_line(*args, **options, &)
Source
clear_lines(*args, **options)
Source
clear_lines(*args, **options, &)
Source
collect

Gathers more than one answer

Example:

prompt.collect do
  key(:name).ask("Name?")
  key(:age).ask("Age?")
end
Source
confirm(message = "", **options, &block : EnhancedConfirm -> )

Ask for enhanced confirmation, especially for destructive operations

Example:

prompt.confirm("Delete all files?", destructive: true)
prompt.confirm("Deploy to production?", double_confirm: true)
Source
confirm(message = "", **options)

ditto

Source
count_screen_lines(*args, **options)
Source
count_screen_lines(*args, **options, &)
Source
cursor
Source
debug(*messages)

Print debug information in terminal top right corner.

Source
decorate(message, color = @palette.enabled)

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

Source
directory_select(question, **options, &block : FileSelect -> )

Ask user to select a directory

Example:

prompt.directory_select("Choose a directory:")
Source
directory_select(question, **options)

ditto

Source
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)
Source
enum_select(question, choices = nil, **options)

ditto

Source
env=(env : Hash(String, String))
Source
error(*args, **options)

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

Source
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)
Source
expand(question, choices = nil, **options)

ditto

Source
file_select(question, **options, &block : FileSelect -> )

Ask user to select a file

Example:

prompt.file_select("Choose a file:")
# or with filters
prompt.file_select("Choose a Ruby file:", filter: [".rb", ".crystal"])
Source
file_select(question, **options)

ditto

Source
flush(*args, **options)
Source
flush(*args, **options, &)
Source
hide(*args, **options)
Source
hide(*args, **options, &)
Source
input
Source
input=(input : IO::FileDescriptor)
Source
interrupt
Source
interrupt=(interrupt : Symbol)
Source
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])
Source
keypress(message = "", **options)

ditto

Source
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:")
Source
mask(message = "", **options)

ditto

Source
multi_select(question, choices = nil, **options, &block : MultiList -> )

Ask a question with multiple attributes activated

Example:

prompt.multi_select("What sizes?") do |menu|
  menu.choice :large
  menu.choices %w(:medium :small)
end
Source
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)
Source
multiline(message = "", **options, &block : Multiline -> )

Ask a question with a multiline answer

Example:

prompt.multiline("Description?")
Source
multiline(message = "", **options)

ditto

Source
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?")
Source
no?(message = "", **options)

ditto

Source
ok(*args, **options)

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

Source
output
Source
output=(output : IO::FileDescriptor)
Source
palette
Source
palette=(palette : Palette)
Source
path_select(question, **options, &block : FileSelect -> )

Ask user to select a file or directory

Example:

prompt.path_select("Choose a path:")
Source
path_select(question, **options)

ditto

Source
prefix
Source
prefix=(prefix : String)
Source
puts(*args, **options)
Source
puts(*args, **options, &)
Source
read_char(*args, **options)
Source
read_char(*args, **options, &)
Source
read_keypress(*args, **options)
Source
read_keypress(*args, **options, &)
Source
read_line(*args, **options)
Source
read_line(*args, **options, &)
Source
read_multiline(*args, **options)
Source
read_multiline(*args, **options, &)
Source
reader
Source
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)
Source
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
Source
select(question, choices = nil, **options)

Ask a question with a list of options

Example:

prompt.select("What size?", %w(large medium small))
Source
show(*args, **options)
Source
show(*args, **options, &)
Source
slider(question, **options, &block : Slider -> )

Ask a question with a range slider

Example:

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

ditto

Source
symbols(new_symbols = nil)

Change symbols used by this prompt

Source
track_history
Source
track_history=(track_history : Bool)
Source
trigger(*args, **options)
Source
trigger(*args, **options, &)
Source
warn(*args, **options)

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

Source
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?")
Source
yes?(message = "", **options)

ditto

Source

Nested types