| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::VTide::Command::Grep; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2016-02-05 10:11:54 |
|
4
|
|
|
|
|
|
|
# Create by: Ivan Wills |
|
5
|
|
|
|
|
|
|
# $Id$ |
|
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
|
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1051
|
use Moo; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
10
|
1
|
|
|
1
|
|
2528
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
26
|
|
|
11
|
1
|
|
|
1
|
|
4
|
use version; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
5
|
|
|
12
|
1
|
|
|
1
|
|
82
|
use Carp; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
47
|
|
|
13
|
1
|
|
|
1
|
|
6
|
use English qw/ -no_match_vars /; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
5
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
extends 'App::VTide::Command::Run'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = version->new('1.0.2'); |
|
18
|
|
|
|
|
|
|
our $NAME = 'grep'; |
|
19
|
|
|
|
|
|
|
our $OPTIONS = [ 'test|T!', 'verbose|v+', ]; |
|
20
|
|
|
|
|
|
|
our $LOCAL = 1; |
|
21
|
0
|
|
|
0
|
1
|
|
sub details_sub { return ( $NAME, $OPTIONS, $LOCAL ) } |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub run { |
|
24
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my ($name) = $self->env; |
|
27
|
0
|
|
|
|
|
|
my $cmd = $self->options->files->[0]; |
|
28
|
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $params = $self->params($cmd); |
|
30
|
0
|
|
|
|
|
|
my ( @files, @grep, $start ); |
|
31
|
0
|
|
|
|
|
|
$start = 1; |
|
32
|
0
|
|
|
|
|
|
for my $file ( @{ $self->options->files } ) { |
|
|
0
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
if ( $file eq '--' ) { |
|
|
|
0
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
$start = 0; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
elsif ($start) { |
|
37
|
0
|
|
|
|
|
|
push @files, $file; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
else { |
|
40
|
0
|
|
|
|
|
|
push @grep, $file; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$params->{editor}{command} = []; |
|
45
|
0
|
|
|
|
|
|
$params->{edit} = \@files; |
|
46
|
0
|
|
|
|
|
|
my @cmd = $self->command($params); |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
0
|
0
|
|
|
|
if ( $params->{env} && ref $params->{env} eq 'HASH' ) { |
|
49
|
0
|
|
|
|
|
|
for my $env ( keys %{ $params->{env} } ) { |
|
|
0
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $orig = $ENV{$env}; |
|
51
|
0
|
|
|
|
|
|
$ENV{$env} = $params->{env}{$env}; |
|
52
|
0
|
|
|
|
|
|
$ENV{$env} =~ s/[\$]$env/$orig/xms; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$self->load_env( $params->{env} ); |
|
57
|
0
|
|
|
|
|
|
$self->hooks->run( 'grepping', \@cmd ); |
|
58
|
0
|
|
0
|
|
|
|
$self->runit( ( $params->{grep} || 'grep' ), @grep, @cmd ); |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub auto_complete { |
|
64
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $env = $self->options->files->[-1]; |
|
67
|
0
|
|
|
|
|
|
my @files = sort keys %{ $self->config->get->{editor}{files} }; |
|
|
0
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
eval { |
|
70
|
0
|
|
|
|
|
|
my $helper = $self->config->get->{editor}{helper_autocomplete}; |
|
71
|
0
|
0
|
|
|
|
|
if ($helper) { |
|
72
|
0
|
|
|
|
|
|
$helper = eval $helper; ## no critic |
|
73
|
0
|
|
|
|
|
|
push @files, $helper->(); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
0
|
|
|
|
|
|
1; |
|
76
|
0
|
0
|
|
|
|
|
} or do { warn $@ }; |
|
|
0
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
print join ' ', grep { $env ne 'grep' ? /^$env/xms : 1 } @files; |
|
|
0
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
return; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 NAME |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
App::VTide::Command::Grep - Run a grep command on vtide editor globs |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 VERSION |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This documentation refers to App::VTide::Command::Grep version 1.0.2 |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
vtide grep (glob ...) -- (grep-options) |
|
98
|
|
|
|
|
|
|
vtide grep [--help|--man] |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
OPTIONS: |
|
101
|
|
|
|
|
|
|
-T --test Test the running of the terminal (shows the commands |
|
102
|
|
|
|
|
|
|
that would be executed) |
|
103
|
|
|
|
|
|
|
-v --verbose Show more verbose output. |
|
104
|
|
|
|
|
|
|
--help Show this help |
|
105
|
|
|
|
|
|
|
--man Show full documentation |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
The C<edit> command allows an ad hoc access to starting the editor with lists |
|
110
|
|
|
|
|
|
|
of files, file groups or globs. The file groups are those defined in the |
|
111
|
|
|
|
|
|
|
local C<.vtide.yml> config (as defined in L<App::VTide::Configuration/editor>). |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 C<run ()> |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Run an editor command with passed in file globs |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 C<auto_complete ()> |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Auto completes editor file groups |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 C<details_sub ()> |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Returns the commands details. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 HOOKS |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 C<edit_editing ($cmd)> |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Called just before execution, the command that will be executed is |
|
132
|
|
|
|
|
|
|
passed and can be modified. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
There are no known bugs in this module. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Please report problems to Ivan Wills (ivan.wills@gmail.com). |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Patches are welcome. |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 AUTHOR |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Ivan Wills - (ivan.wills@gmail.com) |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Copyright (c) 2016 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). |
|
157
|
|
|
|
|
|
|
All rights reserved. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
|
160
|
|
|
|
|
|
|
the same terms as Perl itself. See L<perlartistic>. This program is |
|
161
|
|
|
|
|
|
|
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|
162
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
|
163
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |