/[Frey]/trunk/lib/Frey/Shell/Grep.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/Shell/Grep.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 665 by dpavlin, Mon Dec 1 22:44:41 2008 UTC revision 666 by dpavlin, Tue Dec 2 00:26:03 2008 UTC
# Line 18  has pattern => ( Line 18  has pattern => (
18  sub as_markup {  sub as_markup {
19          my ($self) = @_;          my ($self) = @_;
20    
21          my $patt = $self->pattern || 'FIXME';          my $patt = $self->pattern;
22    
23          $self->title( $patt );          $self->title( $patt );
24    
25          my $cmd = 'grep -rn ' . $patt . ' lib/ t/';          my $cmd = 'grep -rn ' . $patt . ' lib/ t/';
26          warn "# $cmd";          warn "# $cmd";
27    
         my $html = qq|<h1>$patt</h1><dl>|;  
28          my $last_path = '';          my $last_path = '';
29    
30          $self->add_css(qq|          $self->add_css(qq|
# Line 38  sub as_markup { Line 37  sub as_markup {
37                  }                  }
38          |);          |);
39    
40            my $html;
41    
42          open(my $fh, '-|', $cmd) || die "can't open pipe to $cmd $!";          open(my $fh, '-|', $cmd) || die "can't open pipe to $cmd $!";
43          while(<$fh>) {          while(<$fh>) {
44                  my ( $path, $line, $text ) = split(/:/,$_,3);                  my ( $path, $line, $text ) = split(/:/,$_,3);
# Line 50  sub as_markup { Line 51  sub as_markup {
51          }          }
52          if ( $INPUT_LINE_NUMBER > 0 ) { # closing pipe grep output results in error          if ( $INPUT_LINE_NUMBER > 0 ) { # closing pipe grep output results in error
53                  close($fh) || die "can't close pipe to $cmd $!";                  close($fh) || die "can't close pipe to $cmd $!";
         }  
54    
55          $html .= qq|</dl>|;                  $html = qq|
56                            <h1>$patt</h1>
57                            <dl>$html</dl>
58                    |;
59    
60            } else {
61    
62                    $html = $self->error( "No results for $patt\n" );
63    
64            }
65    
66          return $html;          return $html;
67  }  }

Legend:
Removed from v.665  
changed lines
  Added in v.666

  ViewVC Help
Powered by ViewVC 1.1.26