class Athena::Console::Question::Confirmation
Overview
Allows prompting the user to confirm an action.
question = ACON::Question::Confirmation.new "Continue with this action?", false
if !helper.ask input, output, question
return ACON::Command::Status::SUCCESS
end
# ...
In this example the user will be asked if they wish to Continue with this action
.
The #ask
method will return true
if the user enters anything starting with y
, otherwise false
.
Defined in:
question/confirmation.crConstructors
-
.new(question : String, default : Bool = true, true_answer_regex : Regex = /^y/i)
Creates a new instance of self with the provided question string.
Instance methods inherited from class Athena::Console::Question(Bool)
validator : Proc(T, T) | Nilvalidator(&validator : T -> T) : Nil validator, validator=(validator : Proc(T, T) | Nil) validator=
Constructor methods inherited from class Athena::Console::Question(Bool)
new(question : String, default : T)
new
Instance methods inherited from module Athena::Console::Question::Base(Bool)
default : T
default,
hidden=(hidden : Bool) : self
hidden=,
hidden? : Bool
hidden?,
hidden_fallback=(hidden_fallback : Bool)
hidden_fallback=,
hidden_fallback? : Bool
hidden_fallback?,
max_attempts : Int32 | Nil
max_attempts,
max_attempts=(attempts : Int32 | Nil) : self
max_attempts=,
multi_line=(multi_line : Bool)
multi_line=,
multi_line? : Bool
multi_line?,
normalizer : Proc(T | String, T) | Nilnormalizer(&normalizer : T | String -> T) : Nil normalizer, normalizer=(normalizer : Proc(T | String, T) | Nil) normalizer=, question : String question, trimmable=(trimmable : Bool) trimmable=, trimmable? : Bool trimmable?
Constructor methods inherited from module Athena::Console::Question::Base(Bool)
new(question : String, default : T)
new
Constructor Detail
Creates a new instance of self with the provided question string.
The default parameter represents the value to return if no valid input was entered.
The true_answer_regex can be used to customize the pattern used to determine if the user's input evaluates to true
.