Permalink
Browse files

Basic documentation / placeholder, in pod format.

  • Loading branch information...
1 parent f08759a commit c7500162a91b46b5e52e5e8214fae5ee6d02442d Panu Ervamaa committed Apr 28, 2009
Showing with 98 additions and 7 deletions.
  1. +2 −6 README
  2. +7 −1 lib/IO/Prompt.pm
  3. +89 −0 lib/IO/Prompt.pod
View
8 README
@@ -16,10 +16,6 @@ $ PERL6LIB=../proto/lib perl6 Configure.p6
$ make test
$ PERL6LIB=lib perl6 example.p6
-Have fun.
-Proper documentation not done yet.
-See example.p6 and lib/IO/Prompt.pm
+$ perldoc lib/IO/Prompt
-
-(C) Copyright 2009 by Panu Ervamaa.
-The license is Artistic 2.0.
+See also example.p6 and lib/IO/Prompt.pm
View
@@ -1,7 +1,7 @@
use v6;
-
class IO::Prompt {
+
## Exported functional frontend
##
sub ask ( Str $message, $default?, :$type ) is export {
@@ -47,6 +47,7 @@ method ask ( Str $message=$!message,
return $r;
}
+
## The low-level IO methods. Override for testing etc.
##
method !do_prompt ( Str $question? ) returns Str {
@@ -60,6 +61,7 @@ method !do_say ( Str $output ) returns Bool {
## Return False, if there is no point to continue
}
+
## The strings and rules used in the low-level
## query methods. Override these class attributes
## for localization etc.
@@ -77,6 +79,7 @@ our Str $.lang_prompt_num_retry = 'Please enter a valid number';
our Str $.lang_prompt_str = 'Str';
our Str $.lang_prompt_str_retry = 'Please enter a valid string';
+
## Object evaluation in various contexts (type coersion)
##
method true {
@@ -122,6 +125,7 @@ method ask_yn ( Str $message=$!message,
return $result // Bool;
}
+
## Only Integers
##
method ask_int ( Str $message=$!message,
@@ -149,6 +153,7 @@ method ask_int ( Str $message=$!message,
return $result // Int;
}
+
## Numeric type, can hold integers, numbers and eventually rationals
##
method ask_num ( Str $message=$!message,
@@ -177,6 +182,7 @@ method ask_num ( Str $message=$!message,
return $result // Num;
}
+
## Str type, can hold anything that can be read from IO
## (not sure if this is true...?) This is the default.
##
View
@@ -0,0 +1,89 @@
+=head1 NAME
+
+IO::Prompt -- Interactive validating terminal prompt
+
+
+=head1 VERSION
+
+This document describes IO::Prompt version 0.0
+
+
+=head1 SYNOPSIS
+
+ use IO::Prompt;
+
+ my $n = ask('How many bananas?',7);
+ say "You said $n bananas";
+
+See F<example.p6> and F<lib/IO/Prompt.pm> for more
+examples of usage.
+
+=head1 DESCRIPTION
+
+This is a generic module for interactive prompting
+from the console. You can install it with proto:
+
+ $ cd ~/devel
+ $ git clone git://github.com/masak/proto.git
+ $ cd proto
+ $ ./proto
+ $ ./proto install io-prompt
+ $ cd ../io-prompt
+
+ # I assume you have perl6 (rakudo) in your path
+
+ $ PERL6LIB=../proto/lib perl6 Configure.p6
+ $ make test
+ $ PERL6LIB=lib perl6 example.p6
+
+
+=head1 INTERFACE
+
+
+=head1 CONFIGURATION AND ENVIRONMENT
+
+IO::Prompt requires no configuration files or environment variables.
+
+
+=head1 DEPENDENCIES
+
+Requires no external modules. Tested and built with Rakudo Perl 6,
+revision 38379 built on parrot 1.1.0-devel.
+
+
+=head1 AUTHOR
+
+Panu Ervamaa C<< <PNU@cpan.org> >>
+
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright (c) 2009, Panu Ervamaa C<< <PNU@cpan.org> >>.
+All rights reserved.
+
+This module is free software; you can redistribute it and/or
+modify it under the same terms as Rakudo Perl 6 itself.
+
+
+=head1 DISCLAIMER OF WARRANTY
+
+BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
+EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
+ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
+YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
+NECESSARY SERVICING, REPAIR, OR CORRECTION.
+
+IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
+LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
+OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
+THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.

0 comments on commit c750016

Please sign in to comment.