4 # Modules - show information about modules and their maintainers
10 require "$Bin/Modules.pl";
11 use vars qw(%Modules %Maintainers);
18 $0: Usage: $0 [[--maintainer M --module M --files]|file ...]
19 $0 --maintainer M list all maintainers matching M
20 $0 --module M list all modules matching M
21 $0 --files list all files of the module
22 Matching is case-ignoring regexp, author matching is both by
23 the short id and by the full name and email.
24 $0 file ... list the module and maintainer
36 'maintainer=s' => \$Maintainer,
37 'module=s' => \$Module,
43 usage() if @Files && ($Maintainer || $Module || $Files);
45 for my $mean ($Maintainer, $Module) {
46 warn "$0: Did you mean '$0 $mean'?\n"
47 if $mean && -e $mean && $mean ne '.';
50 warn "$0: Did you mean '$0 -mo $Maintainer'?\n"
51 if defined $Maintainer && exists $Modules{$Maintainer};
53 warn "$0: Did you mean '$0 -ma $Module'?\n"
54 if defined $Module && exists $Maintainers{$Module};
58 split ' ', $Modules{$m}{FILES};
61 sub get_module_files {
63 sort { lc $a cmp lc $b }
65 -f $_ ? # Files as-is.
67 -d _ ? # Recurse into directories.
72 push @files, $File::Find::name
77 : glob($_) # The rest are globbable patterns.
81 sub get_maintainer_modules {
83 sort { lc $a cmp lc $b }
84 grep { $Modules{$_}{MAINTAINER} eq $m }
89 for my $m (sort keys %Maintainers) {
90 if ($m =~ /$Maintainer/io) {
91 my @modules = get_maintainer_modules($m);
93 @modules = grep { /$Module/io } @modules;
97 for my $module (@modules) {
98 push @files, get_module_files($module);
100 printf "%-15s @files\n", $m;
103 printf "%-15s @modules\n", $m;
105 printf "%-15s $Maintainers{$m}\n", $m;
111 for my $m (sort { lc $a cmp lc $b } keys %Modules) {
112 if ($m =~ /$Module/io) {
114 my @files = get_module_files($m);
115 printf "%-15s @files\n", $m;
117 printf "%-15s $Modules{$m}{MAINTAINER}\n", $m;
124 @ModuleByFile{@Files} = ();
126 # First try fast match.
129 for my $module (keys %Modules) {
130 for my $pat (get_module_pat($module)) {
131 $ModuleByPat{$pat} = $module;
136 for my $pat (keys %ModuleByPat) {
138 $ExpModuleByPat{$pat} = $ModuleByPat{$pat};
140 for my $exp (glob($pat)) {
141 $ExpModuleByPat{$exp} = $ModuleByPat{$pat};
145 %ModuleByPat = %ExpModuleByPat;
146 for my $file (@Files) {
147 $ModuleByFile{$file} = $ModuleByPat{$file}
148 if exists $ModuleByPat{$file};
151 # If still unresolved files..
152 if (my @ToDo = grep { !defined $ModuleByFile{$_} } keys %ModuleByFile) {
154 # Cannot match what isn't there.
155 @ToDo = grep { -e $_ } @ToDo;
158 # Try prefix matching.
160 # Remove trailing slashes.
161 for (@ToDo) { s|/$|| }
166 for my $pat (keys %ModuleByPat) {
167 last unless keys %ToDo;
170 for my $file (keys %ToDo) {
171 if ($file =~ m|^$pat|i) {
172 $ModuleByFile{$file} = $ModuleByPat{$pat};
182 for my $file (@Files) {
183 if (defined $ModuleByFile{$file}) {
184 my $module = $ModuleByFile{$file};
185 my $maintainer = $Modules{$ModuleByFile{$file}}{MAINTAINER};
186 printf "%-15s $module $maintainer $Maintainers{$maintainer}\n", $file;
188 printf "%-15s ?\n", $file;