line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=encoding utf-8 |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
App::Greple::type - file type filter module for greple |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
greple -Mdig -Mtype --type-xxxx ... --dig . |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This module filters search target files by given rule. It is |
14
|
|
|
|
|
|
|
convenient to use with other B module which support recursive |
15
|
|
|
|
|
|
|
or multi-file search such as B<-Mfind>, B<-Mdig> or B<-Mgit>. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
For example, option for Perl is defined as this: |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
option --type-perl \ |
20
|
|
|
|
|
|
|
--suffix=pl,PL,pm,pod,t,psgi \ |
21
|
|
|
|
|
|
|
--shebang=perl |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Using this option, only files those name end with B<--suffix> option |
24
|
|
|
|
|
|
|
or files which contains string C in the first C<#!> (shebang) |
25
|
|
|
|
|
|
|
line will be searched. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Option B<--suffix> and B<--shebang> are defined in |
28
|
|
|
|
|
|
|
L module. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 CONFIGURATION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=over 7 |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item B<-Mtype::config>(I[=I]) |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
B<-Mtype> module can be called with B function to control |
37
|
|
|
|
|
|
|
module behavior. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=over 4 |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item B |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Calling as B<-Mtype::config(short)> or B<-Mtype::config=short> |
44
|
|
|
|
|
|
|
introduce short name for rule options. When short name mode is |
45
|
|
|
|
|
|
|
activated, all B<--type-xxxx> options can be used as B<--xxxx> as |
46
|
|
|
|
|
|
|
well. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=back |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=back |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 OPTIONS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
option --type-actionscript --suffix=as,mxml |
55
|
|
|
|
|
|
|
option --type-ada --suffix=ada,adb,ads |
56
|
|
|
|
|
|
|
option --type-asm --suffix=asm,s |
57
|
|
|
|
|
|
|
option --type-asp --suffix=asp |
58
|
|
|
|
|
|
|
option --type-aspx --suffix=master,ascx,asmx,aspx,svc |
59
|
|
|
|
|
|
|
option --type-batch --suffix=bat,cmd |
60
|
|
|
|
|
|
|
option --type-cc --suffix=c,h,xs |
61
|
|
|
|
|
|
|
option --type-cfmx --suffix=cfc,cfm,cfml |
62
|
|
|
|
|
|
|
option --type-clojure --suffix=clj |
63
|
|
|
|
|
|
|
option --type-cmake --suffix=cmake --select-name=^CMakeLists.txt$ |
64
|
|
|
|
|
|
|
option --type-coffeescript --suffix=coffee |
65
|
|
|
|
|
|
|
option --type-cpp --suffix=cpp,cc,cxx,m,hpp,hh,h,hxx,c++,h++ |
66
|
|
|
|
|
|
|
option --type-csharp --suffix=cs |
67
|
|
|
|
|
|
|
option --type-css --suffix=css |
68
|
|
|
|
|
|
|
option --type-dart --suffix=dart |
69
|
|
|
|
|
|
|
option --type-delphi --suffix=pas,int,dfm,nfm,dof,dpk,dproj,groupproj,bdsgroup,bdsproj |
70
|
|
|
|
|
|
|
option --type-elisp --suffix=el |
71
|
|
|
|
|
|
|
option --type-elixir --suffix=ex,exs |
72
|
|
|
|
|
|
|
option --type-erlang --suffix=erl,hrl |
73
|
|
|
|
|
|
|
option --type-fortran --suffix=f,f77,f90,f95,f03,for,ftn,fpp |
74
|
|
|
|
|
|
|
option --type-go --suffix=go |
75
|
|
|
|
|
|
|
option --type-groovy --suffix=groovy,gtmpl,gpp,grunit,gradle |
76
|
|
|
|
|
|
|
option --type-haskell --suffix=hs,lhs |
77
|
|
|
|
|
|
|
option --type-hh --suffix=h |
78
|
|
|
|
|
|
|
option --type-html --suffix=htm,html |
79
|
|
|
|
|
|
|
option --type-java --suffix=java,properties |
80
|
|
|
|
|
|
|
option --type-js --suffix=js |
81
|
|
|
|
|
|
|
option --type-json --suffix=json |
82
|
|
|
|
|
|
|
option --type-jsp --suffix=jsp,jspx,jhtm,jhtml |
83
|
|
|
|
|
|
|
option --type-less --suffix=less |
84
|
|
|
|
|
|
|
option --type-lisp --suffix=lisp,lsp |
85
|
|
|
|
|
|
|
option --type-lua --suffix=lua --shebng=lua |
86
|
|
|
|
|
|
|
option --type-markdown --suffix=md |
87
|
|
|
|
|
|
|
option --type-md --type-markdown |
88
|
|
|
|
|
|
|
option --type-make --suffix=mak,mk --select-name=^(GNUmakefile|Makefile|makefile)$ |
89
|
|
|
|
|
|
|
option --type-matlab --suffix=m |
90
|
|
|
|
|
|
|
option --type-objc --suffix=m,h |
91
|
|
|
|
|
|
|
option --type-objcpp --suffix=mm,h |
92
|
|
|
|
|
|
|
option --type-ocaml --suffix=ml,mli |
93
|
|
|
|
|
|
|
option --type-parrot --suffix=pir,pasm,pmc,ops,pod,pg,tg |
94
|
|
|
|
|
|
|
option --type-perl --suffix=pl,PL,pm,pod,t,psgi --shebang=perl |
95
|
|
|
|
|
|
|
option --type-perltest --suffix=t |
96
|
|
|
|
|
|
|
option --type-php --suffix=php,phpt,php3,php4,php5,phtml --shebang=php |
97
|
|
|
|
|
|
|
option --type-plone --suffix=pt,cpt,metadata,cpy,py |
98
|
|
|
|
|
|
|
option --type-python --suffix=py --shebang=python |
99
|
|
|
|
|
|
|
option --type-rake --select-name=^Rakefile$ |
100
|
|
|
|
|
|
|
option --type-rr --suffix=R |
101
|
|
|
|
|
|
|
option --type-ruby --suffix=rb,rhtml,rjs,rxml,erb,rake,spec \ |
102
|
|
|
|
|
|
|
--select-name=^Rakefile$ --shebang=ruby |
103
|
|
|
|
|
|
|
option --type-rust --suffix=rs |
104
|
|
|
|
|
|
|
option --type-sass --suffix=sass,scss |
105
|
|
|
|
|
|
|
option --type-scala --suffix=scala |
106
|
|
|
|
|
|
|
option --type-scheme --suffix=scm,ss |
107
|
|
|
|
|
|
|
option --type-shell --suffix=sh,bash,csh,tcsh,ksh,zsh,fish \ |
108
|
|
|
|
|
|
|
--shebang=sh,bash,csh,tcsh,ksh,zsh,fish |
109
|
|
|
|
|
|
|
option --type-smalltalk --suffix=st |
110
|
|
|
|
|
|
|
option --type-sql --suffix=sql,ctl |
111
|
|
|
|
|
|
|
option --type-tcl --suffix=tcl,itcl,itk |
112
|
|
|
|
|
|
|
option --type-tex --suffix=tex,cls,sty |
113
|
|
|
|
|
|
|
option --type-tt --suffix=tt,tt2,ttml |
114
|
|
|
|
|
|
|
option --type-vb --suffix=bas,cls,frm,ctl,vb,resx |
115
|
|
|
|
|
|
|
option --type-verilog --suffix=v,vh,sv |
116
|
|
|
|
|
|
|
option --type-vim --suffix=vim |
117
|
|
|
|
|
|
|
option --type-xml --suffix=xml,dtd,xsl,xslt,ent --select-data='\A.*<[?]xml' |
118
|
|
|
|
|
|
|
option --type-yaml --suffix=yaml,yml |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 BACKGROUND |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This module is inspired by L command, and original matching |
123
|
|
|
|
|
|
|
rule is taken from it. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Filename matching can be done with B<-Mfind> module, but to know file |
126
|
|
|
|
|
|
|
type from its content, different mechanism was required. So I made |
127
|
|
|
|
|
|
|
the B<--begin> function can die to stop the file processing, and |
128
|
|
|
|
|
|
|
introduced new B<-Mselect> module. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 SEE ALSO |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
L, L |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
L |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 AUTHOR |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Kazumasa Utashiro |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 LICENSE |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Copyright 2021-2022 Kazumasa Utashiro. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
145
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
package App::Greple::type; |
150
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
151
|
|
|
|
|
|
|
|
152
|
1
|
|
|
1
|
|
724
|
use v5.14; |
|
1
|
|
|
|
|
3
|
|
153
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
154
|
1
|
|
|
1
|
|
532
|
use Data::Dumper; |
|
1
|
|
|
|
|
5783
|
|
|
1
|
|
|
|
|
219
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
my($module, $argv); |
157
|
|
|
|
|
|
|
my %opt; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub initialize { |
160
|
0
|
|
|
0
|
0
|
|
($module, $argv) = @_; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub config { |
164
|
0
|
|
|
0
|
1
|
|
while (my($k, $v) = splice @_, 0, 2) { |
165
|
0
|
|
|
|
|
|
$opt{$k} = $v; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub finalize { |
170
|
0
|
0
|
|
0
|
0
|
|
if ($opt{short}) { |
171
|
0
|
|
|
|
|
|
my @options = $module->options; |
172
|
0
|
|
|
|
|
|
for my $opt (@options) { |
173
|
0
|
0
|
|
|
|
|
$opt =~ /^--type-(.+)/ or next; |
174
|
0
|
|
|
|
|
|
$module->setopt("--$1", $opt); |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
} |
177
|
0
|
0
|
|
|
|
|
warn Dumper $module if $opt{dump}; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
1; |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
__DATA__ |