1 package CPANPLUS::Shell::Default::Plugins::Source;
4 use CPANPLUS::Error qw[error msg];
5 use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext';
9 CPANPLUS::Shell::Default::Plugins::Source
13 CPAN Terminal> /source /tmp/list_of_commands /tmp/more_commands
17 This is a C<CPANPLUS::Shell::Default> plugin that works just like
18 your unix shells source(1) command; it reads in a file that has
19 commands in it to execute, and then executes them.
21 A sample file might look like this:
23 # first, update all the source files
26 # find all of my modules that are on the CPAN
27 # test them, and store the error log
30 p /home/kane/cpan-autotest/log
32 # and inform us we're good to go
33 ! print "Autotest complete, log stored; please enter your commands!"
35 Note how empty lines, and lines starting with a '#' are being skipped
41 sub plugins { return ( source => 'source' ) }
48 my $input = shift || '';
49 my $opts = shift || {};
50 my $verbose = $cb->configure_object->get_conf('verbose');
52 for my $file ( split /\s+/, $input ) {
53 my $fh = FileHandle->new("$file") or(
54 error(loc("Could not open file '%1': %2", $file, $!)),
58 while( my $line = <$fh> ) {
61 next if $line !~ /\S+/; # skip empty/whitespace only lines
62 next if $line =~ /^#/; # skip comments
64 msg(loc("Dispatching '%1'", $line), $verbose);
65 return 1 if $shell->dispatch_on_input( input => $line );
71 return loc(' /source FILE [FILE ..] '.
72 '# read in commands from the specified file' ),
81 Please report bugs or other issues to E<lt>bug-cpanplus@rt.cpan.org<gt>.
85 This module by Jos Boumans E<lt>kane@cpan.orgE<gt>.
89 The CPAN++ interface (of which this module is a part of) is copyright (c)
90 2001 - 2007, Jos Boumans E<lt>kane@cpan.orgE<gt>. All rights reserved.
92 This library is free software; you may redistribute and/or modify it
93 under the same terms as Perl itself.
97 L<CPANPLUS::Shell::Default>, L<CPANPLUS::Shell>, L<cpanp>
102 # c-indentation-style: bsd
104 # indent-tabs-mode: nil
106 # vim: expandtab shiftwidth=4: