--- /dev/null
+package CatalystX::HelpText::Script::SearchUndocumentedHelpText;
+use Moose;
+use Moose::Autobox;
+use MooseX::Types::Path::Class qw/ Dir /;
+use MooseX::Types::Moose qw/Str Undef/;
+use File::Find;
+use Data::Dumper;
+use Getopt::Long::Descriptive; # Force GLD as we override bits..
+use namespace::autoclean;
+
+has help_files_path => (
+ is => 'ro',
+ isa => Dir,
+ coerce => 1,
+ required => 1,
+ handles => {
+ _get_file => 'file',
+ }
+);
+
+has template_search_dir => (
+ is => 'ro',
+ isa => Str,
+ default => './',
+);
+
+has filename_pattern => (
+ is => 'ro',
+ isa => Str,
+ default => '\.(html|tt)$',
+);
+
+has help_files_ext => (
+ is => 'ro',
+ isa => Str|Undef,
+ default => 'html',
+);
+
+sub run {
+ my ($self) = @_;
+ my $filename_pattern = $self->filename_pattern;
+ my %helpkeys = ();
+ find(
+ {
+ wanted => sub {
+ my $filename = $File::Find::name;
+ return unless -f $filename;
+ return unless $filename =~ /$filename_pattern/;
+
+ #warn $filename;
+ open(FILE, $filename) or warn "Can't open $filename\n" && return;
+ while (<FILE>) {
+ if (my ($key) = m/help_text\('(.*)'\)/o) {
+ $helpkeys{$key} = 1;
+ }
+ }
+ close(FILE);
+ },
+ bydepth => 1
+ }, $self->template_search_dir->flatten);
+
+ my @notfound = ();
+ foreach (keys %helpkeys) {
+ my $file = $self->_get_file($_);
+ $file .= "." . $self->help_files_ext if defined($self->help_files_ext);
+ push (@notfound, $file) unless (-e $file);
+ }
+ print "\nMissing Help Text files:\n" if (scalar @notfound);
+ print " - $_\n" for (@notfound);
+}
+
+with qw/
+ MooseX::Getopt
+/;
+
+__PACKAGE__->meta->make_immutable;
+__PACKAGE__->new_with_options->run unless caller;
+
+1;