class
Term::Prompt
- Term::Prompt
- Reference
- Object
Defined in:
prompt/answers_collector.crprompt/autocomplete.cr
prompt/block_paginator.cr
prompt/choice.cr
prompt/choices.cr
prompt/confirm_question.cr
prompt/enhanced_confirm.cr
prompt/enum_list.cr
prompt/expander.cr
prompt/file_select.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
prompt/version.cr
term-prompt.cr
Constant Summary
-
VERSION =
{{ (`shards version /srv/crystaldoc.info/github-crystal-term-prompt-master/src/prompt`).chomp.stringify }}
Constructors
Instance Method Summary
-
#ask(message = "", **options, &block : Question -> )
Ask a question.
-
#ask(message = "", **options)
ditto
-
#autocomplete(question, choices = nil, **options, &block : Autocomplete -> )
Ask a question with autocomplete suggestions
-
#autocomplete(question, choices = nil, **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
-
#confirm(message = "", **options, &block : EnhancedConfirm -> )
Ask for enhanced confirmation, especially for destructive operations
-
#confirm(message = "", **options)
ditto
- #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 = @palette.enabled)
Decorate the provided
messageusing the givencolor. -
#directory_select(question, **options, &block : FileSelect -> )
Ask user to select a directory
-
#directory_select(question, **options)
ditto
-
#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
-
#file_select(question, **options, &block : FileSelect -> )
Ask user to select a file
-
#file_select(question, **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)
-
#path_select(question, **options, &block : FileSelect -> )
Ask user to select a file or directory
-
#path_select(question, **options)
ditto
- #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?")
Ask a question with autocomplete suggestions
Example:
frameworks = %w(Rails Django Flask Laravel Express React Vue Angular)
prompt.autocomplete("Choose a framework:", frameworks)
Gathers more than one answer
Example:
prompt.collect do
key(:name).ask("Name?")
key(:age).ask("Age?")
end
Ask for enhanced confirmation, especially for destructive operations
Example:
prompt.confirm("Delete all files?", destructive: true)
prompt.confirm("Deploy to production?", double_confirm: true)
Decorate the provided message using the given color. Color can be
a symbol, a Color instance, or an {R, G, B} tuple.
Ask user to select a directory
Example:
prompt.directory_select("Choose a directory:")
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 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"])
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?")
Ask user to select a file or directory
Example:
prompt.path_select("Choose a path:")
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?")