1 package CatalystX::HelpText::Script::SearchUndocumentedHelpText;
4 use MooseX::Types::Path::Class qw/ Dir /;
5 use MooseX::Types::Moose qw/Str Undef/;
8 use Getopt::Long::Descriptive; # Force GLD as we override bits..
9 use namespace::autoclean;
11 has help_files_path => (
21 has template_search_dir => (
27 has filename_pattern => (
30 default => '\.(html|tt)$',
33 has help_files_ext => (
41 my $filename_pattern = $self->filename_pattern;
46 my $filename = $File::Find::name;
47 return unless -f $filename;
48 return unless $filename =~ /$filename_pattern/;
50 #FIXME - Not a regex here, we should actually pass the templates through TT
51 # and pass in our own callback!
52 # I guess the 'here is a file name, hand me the list of links in it'
53 # stuff should be delegated to another class (which is settable by command line)
54 # to allow people to have alternative methods of using this
55 open(FILE, $filename) or warn "Can't open $filename\n" && return;
57 if (my ($key) = m/help_text\('(.*)'\)/o) {
64 }, $self->template_search_dir->flatten);
67 foreach (keys %helpkeys) {
68 my $file = $self->_get_file($_);
69 $file .= "." . $self->help_files_ext if defined($self->help_files_ext);
70 push (@notfound, $file) unless (-e $file);
72 # XXX FIXME - This method is way too big!
73 # It'd be useless if you wanted to customise it by sub-classing (which we _will_)
74 # later want to do as part of our build process!
75 # We should have a method to find a list of all the potential files
76 # then a for each file method, which calls to the delegate class and
77 # then we should build a hash of all the filemame => [qw/ helptext1 helptext 2 /]
78 # and then finally we should hand that to a method for pretty printing
79 # (and that method needs to unique the finds, which we don't do at the moment)
80 print "\nMissing Help Text files:\n" if (scalar @notfound);
81 print " - $_\n" for (@notfound);
88 __PACKAGE__->meta->make_immutable;
89 __PACKAGE__->new_with_options->run unless caller;