IO::Prompt::I18N - Prompt user question, with some options (including I18N)
This document describes version 0.80 of IO::Prompt::I18N (from Perl distribution IO-Prompt-I18N), released on 2015-01-03.
use IO::Prompt::I18N qw(prompt confirm); use Text::LocaleDomain 'My-App'; my $file = prompt(__"Enter filename"); if (confirm(__"Really delete filename", {lang=>"id", default=>0})) { unlink $file; }
This module provides the prompt function to ask for a value from STDIN. It features prompt text, default value, validation (using regex), optional/required. It also provides confirm wrapper to ask yes/no, with localizable text.
prompt
confirm
Display $text and ask value from STDIN. Will re-ask if value is not valid. Return the chomp-ed value.
$text
Options:
var => \$var
required => bool
If set to true then will require that value is not empty (zero-length).
default => VALUE
Set default value.
show_default => bool (default: 1)
Whether to show default value if defined.
regex => REGEX
Validate using regex.
Display $text (defaults to Confirm in English) and ask for yes or no. Will return bool. Basically a convenient wrapper around prompt.
Confirm
lang => str
Support several languages (id, en, fr). Default to using LANG/LANGUAGE or English. Will preset yes_words and no_words and adds the choice of words to $text. Will die if language is not supported. Here are the supported languages:
id
en
fr
yes_words
no_words
lang yes_words no_regex default text ---- --------- -------- ------------ en y, yes n, no Confirm fr o, oui n, non Confirmer id y, ya t, tidak Konfirmasi
yes_words => array
Overrides preset from lang.
lang
no_words => array
default => bool
IO::Prompt, IO::Prompt::Tiny, Term::Prompt, Prompt::Timeout
Please visit the project's homepage at https://metacpan.org/release/IO-Prompt-I18N.
Source repository is at https://github.com/perlancar/perl-IO-Prompt-I18N.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=IO-Prompt-I18N
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2015 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install IO::Prompt::I18N, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IO::Prompt::I18N
CPAN shell
perl -MCPAN -e shell install IO::Prompt::I18N
For more information on module installation, please visit the detailed CPAN module installation guide.