Class::Usul::TraitFor::Prompting - Methods for requesting command line input
use Moo; with q(Class::Usul::TraitForPrompting);
Methods that prompt for command line input from the user
Defines no attributes
$key = $self->anykey( $prompt );
Prompt string defaults to 'Press any key to continue...'. Calls and returns prompt. Requires the user to press any key on the keyboard (that generates a character response)
$line = $self->get_line( $question, $default, $quit, $width, $newline );
Prompts the user to enter a single line response to $question which is printed to STDOUT with a program leader. If $quit is true then the options to quit is included in the prompt. If the $width argument is defined then the string is formatted to the specified width which is $width or $self->pwdith or 40. If $newline is true a newline character is appended to the prompt so that the user get a full line of input
$question
$quit
$width
$self->pwdith
$newline
$option = $self->get_option( $question, $default, $quit, $width, $options );
Returns the selected option number from the list of possible options passed in the $question argument
$bool = $self->is_interactive( $optional_filehandle );
Exposes "is_interactive" in IO::Interactive
$line = __prompt( 'key' => 'value', ... );
This was taken from IO::Prompt which has an obscure bug in it. Much simplified the following keys are supported
Return the first character typed
Default response
The character to echo in place of the one typed
Prompt string
$self->yorn( $question, $default, $quit, $width );
Prompt the user to respond to a yes or no question. The $question is printed to STDOUT with a program leader. The $default argument is 0|1. If $quit is true then the option to quit is included in the prompt. If the $width argument is defined then the string is formatted to the specified width which is $width or $self->pwdith or 40
$default
0|1
($cntrl, %cntrl) = __get_control_chars( $handle );
Returns a string of pipe separated control characters and a hash of symbolic names and values
__raw_mode( $handle );
Puts the terminal in raw input mode
__restore_mode( $handle );
Restores line input mode to the terminal
None
There are no known incompatibilities in this module
There are no known bugs in this module. Please report problems to http://rt.cpan.org/NoAuth/Bugs.html?Dist=Class-Usul. Patches are welcome
Larry Wall - For the Perl programming language
Peter Flanigan, <pjfl@cpan.org>
<pjfl@cpan.org>
Copyright (c) 2014 Peter Flanigan. All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
To install Class::Usul, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::Usul
CPAN shell
perl -MCPAN -e shell install Class::Usul
For more information on module installation, please visit the detailed CPAN module installation guide.