From ec069554b263d4d3a60a315089e170b92badd1d8 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 3 Jun 2013 15:18:17 -0500 Subject: start on some docs --- lib/Reply.pm | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) (limited to 'lib/Reply.pm') diff --git a/lib/Reply.pm b/lib/Reply.pm index d32ff05..53808bc 100644 --- a/lib/Reply.pm +++ b/lib/Reply.pm @@ -8,6 +8,71 @@ use Module::Runtime qw(compose_module_name use_package_optimistically); use Scalar::Util qw(blessed); use Try::Tiny; +=head1 SYNOPSIS + + use Reply; + + Reply->new(config => "$ENV{HOME}/.replyrc")->run; + +=head1 DESCRIPTION + +Reply is a lightweight, extensible REPL for Perl. It is plugin-based (see +L), and through plugins supports many advanced features such as +coloring and pretty printing, readline support, and pluggable commands. + +=head1 CONFIGURATION + +Configuration uses an INI-style format similar to the configuration format of +L. Section names are used as the names of plugins, and any options +within a section are passed as arguments to that plugin. Plugins are loaded in +order as they are listed in the configuration file, which can affect the +results in some cases where multiple plugins are hooking into a single callback +(see L for more information). + +In addition to plugin configuration, there are some additional options +recognized. These must be specified at the top of the file, before any section +headers. + +=over 4 + +=item script_file + +This contains a filename whose contents will be evaluated as perl code once the +configuration is done being loaded. + +=item script_lineI + +Any options that start with C will be sorted by their key and then +each value will be evaluated individually once the configuration is done being +loaded. + +NOTE: this is currently a hack due to the fact that L doesn't +support multiple keys with the same name in a section. This may be fixed in the +future to just allow specifying C multiple times. + +=back + +=cut + +=method new(%opts) + +Creates a new Reply instance. Valid options are: + +=over 4 + +=item config + +Name of a configuration file to load. This should contain INI-style +configuration for plugins as described above. + +=item plugins + +An arrayref of additional plugins to load. + +=back + +=cut + sub new { my $class = shift; my %opts = @_; @@ -29,6 +94,14 @@ sub new { return $self; } +=method load_plugin($plugin, $opts) + +Loads the specified plugin. C<$plugin> corresponds to the class +C, which will be loaded and instantiated. If C<$opts> +is given, it should be a hashref of options to pass to the plugin constructor. + +=cut + sub load_plugin { my $self = shift; my ($plugin, $opts) = @_; @@ -44,6 +117,13 @@ sub load_plugin { push @{ $self->{plugins} }, $plugin; } +=method run + +Runs the repl. Will continue looping until the C callback returns +undef. + +=cut + sub run { my $self = shift; @@ -176,4 +256,46 @@ sub _chained_plugin { return @args; } +=head1 BUGS + +No known bugs. + +Please report any bugs through RT: email +C, or browse to +L. + +=head1 SEE ALSO + +L + +=head1 SUPPORT + +You can find this documentation for this module with the perldoc command. + + perldoc Reply + +You can also look for information at: + +=over 4 + +=item * AnnoCPAN: Annotated CPAN documentation + +L + +=item * CPAN Ratings + +L + +=item * RT: CPAN's request tracker + +L + +=item * Search CPAN + +L + +=back + +=cut + 1; -- cgit v1.2.3-54-g00ecf