increment $VERSION after 1.003029 release
[p5sagit/Devel-REPL.git] / README.pod
CommitLineData
dff8f09f 1=pod
2
3=encoding UTF-8
4
5=head1 NAME
6
7Devel::REPL - A modern perl interactive shell
8
9=head1 VERSION
10
2b75dcad 11version 1.003029
dff8f09f 12
13=head1 SYNOPSIS
14
15 my $repl = Devel::REPL->new;
16 $repl->load_plugin($_) for qw(History LexEnv);
17 $repl->run
18
19Alternatively, use the 're.pl' script installed with the distribution
20
21 system$ re.pl
22
23=head1 DESCRIPTION
24
25This is an interactive shell for Perl, commonly known as a REPL - Read,
26Evaluate, Print, Loop. The shell provides for rapid development or testing
27of code without the need to create a temporary source code file.
28
29Through a plugin system, many features are available on demand. You can also
30tailor the environment through the use of profiles and run control files, for
31example to pre-load certain Perl modules when working on a particular project.
32
33=head1 USAGE
34
35To start a shell, follow one of the examples in the L</"SYNOPSIS"> above.
36
37Once running, the shell accepts and will attempt to execute any code given. If
38the code executes successfully you'll be shown the result, otherwise an error
39message will be returned. Here are a few examples:
40
41 $_ print "Hello, world!\n"
42 Hello, world!
43 1
44 $_ nosuchfunction
45 Compile error: Bareword "nosuchfunction" not allowed while "strict subs" in use at (eval 130) line 5.
46
47 $_
48
49In the first example above you see the output of the command (C<Hello,
50world!>), if any, and then the return value of the statement (C<1>). Following
51that example, an error is returned when the execution of some code fails.
52
53Note that the lack of semicolon on the end is not a mistake - the code is
54run inside a Block structure (to protect the REPL in case the code blows up),
55which means a single statement doesn't require the semicolon. You can add one
56if you like, though.
57
58If you followed the first example in the L</"SYNOPSIS"> above, you'll have the
59L<History|Devel::REPL::Plugin::History> and L<LexEnv|Devel::REPL::Plugin::LexEnv>
60plugins loaded (and there are many more available).
61Although the shell might support "up-arrow" history, the History plugin adds
62"bang" history to that so you can re-execute chosen commands (with e.g.
63C<!53>). The LexEnv plugin ensures that lexical variables declared with the
64C<my> keyword will automatically persist between statements executed in the
65REPL shell.
66
67When you C<use> any Perl module, the C<import()> will work as expected - the
68exported functions from that module are available for immediate use:
69
70 $_ carp "I'm dieeeing!\n"
71 String found where operator expected at (eval 129) line 5, near "carp "I'm dieeeing!\n""
72 (Do you need to predeclare carp?)
73 Compile error: syntax error at (eval 129) line 5, near "carp "I'm dieeeing!\n""
74 BEGIN not safe after errors--compilation aborted at (eval 129) line 5.
75
76 $_ use Carp
77
78 $_ carp "I'm dieeeing!\n"
79 I'm dieeeing!
80 at /usr/share/perl5/Lexical/Persistence.pm line 327
81 1
82 $_
83
84To quit from the shell, hit C<Ctrl+D> or C<Ctrl+C>.
85
86 MSWin32 NOTE: control keys won't work if TERM=dumb
87 because readline functionality will be disabled.
88
89=head2 Run Control Files
90
91For particular projects you might well end up running the same commands each
92time the REPL shell starts up - loading Perl modules, setting configuration,
93and so on. A run control file lets you have this done automatically, and you
94can have multiple files for different projects.
95
96By default the C<re.pl> program looks for C<< $HOME/.re.pl/repl.rc >>, and
97runs whatever code is in there as if you had entered it at the REPL shell
98yourself.
99
100To set a new run control file that's also in that directory, pass it as a
101filename like so:
102
103 system$ re.pl --rcfile myproject.pc
104
105If the filename happens to contain a forward slash, then it's used absolutely,
106or realive to the current working directory:
107
108 system$ re.pl --rcfile /path/to/my/project/repl.rc
109
110Within the run control file you might want to load plugins. This is covered in
111L</"The REPL shell object"> section, below.
112
113=head2 Profiles
114
115To allow for the sharing of run control files, you can fashion them into a
116Perl module for distribution (perhaps via the CPAN). For more information on
117this feature, please see the L<Devel::REPL::Profile> manual page.
118
119A C<Standard> profile ships with C<Devel::REPL>; it loads the following plugins
120(note that some of these require optional features -- or you can also use the
121C<Minimal> profile):
122
123=over 4
124
125=item *
126
127L<Devel::REPL::Plugin::History>
128
129=item *
130
131L<Devel::REPL::Plugin::LexEnv>
132
133=item *
134
135L<Devel::REPL::Plugin::DDS>
136
137=item *
138
139L<Devel::REPL::Plugin::Packages>
140
141=item *
142
143L<Devel::REPL::Plugin::Commands>
144
145=item *
146
147L<Devel::REPL::Plugin::MultiLine::PPI>
148
149=item *
150
151L<Devel::REPL::Plugin::Colors>
152
153=item *
154
155L<Devel::REPL::Plugin::Completion>
156
157=item *
158
159L<Devel::REPL::Plugin::CompletionDriver::INC>
160
161=item *
162
163L<Devel::REPL::Plugin::CompletionDriver::LexEnv>
164
165=item *
166
167L<Devel::REPL::Plugin::CompletionDriver::Keywords>
168
169=item *
170
171L<Devel::REPL::Plugin::CompletionDriver::Methods>
172
173=item *
174
175L<Devel::REPL::Plugin::ReadlineHistory>
176
177=back
178
179=head2 Plugins
180
181Plugins are a way to add functionality to the REPL shell, and take advantage of
182C<Devel::REPL> being based on the L<Moose> object system for Perl 5. This
183means it's simple to 'hook into' many steps of the R-E-P-L process. Plugins
184can change the way commands are interpreted, or the way their results are
185output, or even add commands to the shell environment.
186
187A number of plugins ship with C<Devel::REPL>, and more are available on the
188CPAN. Some of the shipped plugins are loaded in the default profile, mentioned
189above. These plugins can be loaded in your F< $HOME/.re.pl/repl.rc > like:
190
191 load_plugin qw( CompletionDriver::Global DumpHistory );
192
193Writing your own plugins is not difficult, and is discussed in the
194L<Devel::REPL::Plugin> manual page, along with links to the manual pages of
195all the plugins shipped with C<Devel::REPL>.
196
197=head2 The REPL shell object
198
199From time to time you'll want to interact with or manipulate the
200C<Devel::REPL> shell object itself; that is, the instance of the shell you're
201currently running.
202
203The object is always available through the C<$_REPL> variable. One common
204requirement is to load an additional plugin, after your profile and run
205control files have already been executed:
206
207 $_ $_REPL->load_plugin('Timing');
208 1
209 $_ print "Hello again, world!\n"
210 Hello again, world!
211 Took 0.00148296356201172 seconds.
212 1
213 $_
214
215=head1 OPTIONAL FEATURES
216
217In addition to the prerequisites declared in this distribution, which should be automatically installed by your L<CPAN> client, there are a number of optional features, used by
218additional plugins. You can install any of these features by installing this
219distribution interactively (e.g. C<cpanm --interactive Devel::REPL>).
220
221=for comment I hope to automatically generate this data via a Pod::Weaver section
222
223=over 4
224
225=item *
226
227Completion plugin - extensible tab completion
228
229=item *
230
231DDS plugin - better format results with Data::Dump::Streamer
232
233=item *
234
235DDC plugin - even better format results with Data::Dumper::Concise
236
237=item *
238
239INC completion driver - tab complete module names in use and require
240
241=item *
242
243Interrupt plugin - traps SIGINT to kill long-running lines
244
245=item *
246
247Keywords completion driver - tab complete Perl keywords and operators
248
249=item *
250
251LexEnv plugin - variables declared with "my" persist between statements
252
253=item *
254
255MultiLine::PPI plugin - continue reading lines until all blocks are closed
256
257=item *
258
259Nopaste plugin - upload a session\'s input and output to a Pastebin
260
261=item *
262
263PPI plugin - PPI dumping of Perl code
264
265=item *
266
267Refresh plugin - automatically reload libraries with Module::Refresh
268
269=back
270
23ff40a3 271=head1 SEE ALSO
272
273=over 4
274
275=item *
276
2b75dcad 277L<A comparison of various REPLs|https://www.shadowcat.co.uk/blog/matt-s-trout/mstpan-17/>
23ff40a3 278
279=back
280
281=head1 SUPPORT
282
283Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Devel-REPL>
284(or L<bug-Devel-REPL@rt.cpan.org|mailto:bug-Devel-REPL@rt.cpan.org>).
285
286There is also an irc channel available for users of this distribution, at
287L<C<#devel> on C<irc.perl.org>|irc://irc.perl.org/#devel-repl>.
288
dff8f09f 289=head1 AUTHOR
290
291Matt S Trout - mst (at) shadowcatsystems.co.uk (L<http://www.shadowcatsystems.co.uk/>)
292
293=head1 CONTRIBUTORS
294
2b75dcad 295=for stopwords Karen Etheridge Shawn M Moore Chris Marshall Matt S Trout Oliver Gorwits יובל קוג'מן (Yuval Kogman) Arthur Axel 'fREW' Schmidt Alexis Sukrieh Andrew epitaph Jesse Luehrs Norbert Buchmuller Tomas Doran (t0m) Dagfinn Ilmari Mannsåker Dave Houston Zakariyya Mughal Ash Berlin Justin Hunter mgrimes naquad Ryan Niebur Stevan Little
dff8f09f 296
297=over 4
298
299=item *
300
301Karen Etheridge <ether@cpan.org>
302
303=item *
304
305Shawn M Moore <code@sartak.org>
306
307=item *
308
309Chris Marshall <devel.chm.01@gmail.com>
310
311=item *
312
313Matt S Trout <mst@shadowcat.co.uk>
314
315=item *
316
317Oliver Gorwits <oliver@cpan.org>
318
319=item *
320
321יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
322
323=item *
324
325Arthur Axel 'fREW' Schmidt <frioux@gmail.com>
326
327=item *
328
2b75dcad 329Alexis Sukrieh <sukria+perl@sukria.net>
dff8f09f 330
331=item *
332
2b75dcad 333Andrew Moore <amoore@cpan.org>
dff8f09f 334
335=item *
336
2b75dcad 337epitaph <unknown>
dff8f09f 338
339=item *
340
2b75dcad 341Jesse Luehrs <doy@tozt.net>
dff8f09f 342
343=item *
344
345Norbert Buchmuller <norbi@nix.hu>
346
347=item *
348
2b75dcad 349Tomas Doran (t0m) <bobtfish@bobtfish.net>
dff8f09f 350
351=item *
352
2b75dcad 353Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
dff8f09f 354
355=item *
356
2b75dcad 357Dave Houston <dhouston@cpan.org>
dff8f09f 358
359=item *
360
361Zakariyya Mughal <zaki.mughal@gmail.com>
362
363=item *
364
2b75dcad 365Ash Berlin <ash_github@firemirror.com>
dff8f09f 366
367=item *
368
369Justin Hunter <justin.d.hunter@gmail.com>
370
371=item *
372
2b75dcad 373mgrimes <mgrimes@cpan.org>
dff8f09f 374
375=item *
376
377naquad <naquad@bd8105ee-0ff8-0310-8827-fb3f25b6796d>
378
379=item *
380
2b75dcad 381Ryan Niebur <ryan@debian.org>
382
383=item *
384
dff8f09f 385Stevan Little <stevan.little@iinteractive.com>
386
387=back
388
23ff40a3 389=head1 COPYRIGHT AND LICENCE
dff8f09f 390
391This software is copyright (c) 2007 by Matt S Trout - mst (at) shadowcatsystems.co.uk (L<http://www.shadowcatsystems.co.uk/>).
392
393This is free software; you can redistribute it and/or modify it under
394the same terms as the Perl 5 programming language system itself.
395
396=cut