Raku Land

IntlPromptYesNo

github:alabamenhu

Το «ναι» και το «όχι», αν και είναι οι πιο σύντομες από όλες τις λέξεις, χρειάζεται να τις σκεφθεί κανείς πολύ προηγουμένως. — Πυθαγόρας

Intl::Prompt::YesNo

A module to ask a user for a yes/no response in a localized command line interface. To use:

use Intl::Prompt::YesNo

my $answer = prompt-yes-no 'Queres falar em português?', :language<pt>;
# Queres falar em português? [s/n]

if $answer { 
  # they answered yes
} else { 
  # they answered no
}

If the user responds in an affirmative manner, the sub prompt-yes-no will return True. If they respond in a negative manner, it returns False.

The sub accepts a single positional argument, which is the message to display alongside the prompt. It would be best to obtain such a string through a module like Fluent. There are two named arguments available:

Version history

© 2020 Matthew Stephen Stuckwisch. Licensed under the Artistic License 2.0. But as this is very simple, feel free to hack this code up and integrate it in your own code without need for attribution.