[Bps-public-commit] r12227 - in Prophet/trunk: .

sartak at bestpractical.com sartak at bestpractical.com
Sun May 11 01:13:15 EDT 2008


Author: sartak
Date: Sun May 11 01:13:15 2008
New Revision: 12227

Modified:
   Prophet/trunk/   (props changed)
   Prophet/trunk/lib/Prophet/CLI.pm

Log:
 r55545 at onn:  sartak | 2008-05-11 01:11:50 -0400
 Prophet::CLI->invoke which overrides *ARGV and lets you choose the output handle


Modified: Prophet/trunk/lib/Prophet/CLI.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI.pm	Sun May 11 01:13:15 2008
@@ -158,6 +158,25 @@
     }
 }
 
+=head2 invoke [outhandle], ARGV
+
+Run the given command. If outhandle is true, select that as the file handle
+for the duration of the command.
+
+=cut
+
+sub invoke {
+    my ($self, $output, @args) = @_;
+    my $ofh;
+
+    local *ARGV = \@args;
+    $ofh = select $output if $output;
+    my $ret = eval { $self->run_one_command };
+    warn $@ if $@;
+    select $ofh if $ofh;
+    return $ret;
+}
+
 package Prophet::CLI::Command;
 
 use base qw/Class::Accessor/;



More information about the Bps-public-commit mailing list