diff --git a/bin/cpancover b/bin/cpancover index 18a64670..83bac572 100755 --- a/bin/cpancover +++ b/bin/cpancover @@ -24,126 +24,129 @@ use Pod::Usage; $|++; my $Options = { - bin_dir => abs_path($0) =~ s|/cpancover$||r, - build => 1, - compress_old_versions => 0, - docker => "docker", - dryrun => 0, - force => 0, - generate_html => 0, - latest => 0, - local => 0, - local_build => 0, - modules => [], - output_file => "index.html", - report => "html_basic", - results_dir => cwd(), - timeout => 7200, # two hours - verbose => 0, - workers => 0, + bin_dir => abs_path($0) =~ s|/cpancover$||r, + build => 1, + compress_old_versions => 0, + docker => "docker", + dryrun => 0, + force => 0, + generate_html => 0, + latest => 0, + local => 0, + local_build => 0, + modules => [], + output_file => "index.html", + report => "html_basic", + results_dir => cwd(), + timeout => 7200, # two hours + verbose => 0, + workers => 0, }; sub get_options { - die "Bad option" unless GetOptions($Options, qw( - bin_dir=s - build! - compress_old_versions=i - docker=s - dryrun! - force! - generate_html! - help|h! - info|i! - latest! - local! - local_build! - module_file=s - modules=s - output_file=s - report=s - results_dir=s - timeout=i - verbose! - version|v! - workers=i - )); - - say "$0 version " . __PACKAGE__->VERSION and exit 0 if $Options->{version}; - pod2usage(-exitval => 0, -verbose => 0) if $Options->{help}; - pod2usage(-exitval => 0, -verbose => 2) if $Options->{info}; + die "Bad option" unless GetOptions( + $Options, qw( + bin_dir=s + build! + compress_old_versions=i + docker=s + dryrun! + force! + generate_html! + help|h! + info|i! + latest! + local! + local_build! + module_file=s + modules=s + output_file=s + report=s + results_dir=s + timeout=i + verbose! + version|v! + workers=i + ) + ); + + say "$0 version " . __PACKAGE__->VERSION and exit 0 if $Options->{version}; + pod2usage(-exitval => 0, -verbose => 0) if $Options->{help}; + pod2usage(-exitval => 0, -verbose => 2) if $Options->{info}; } sub newcp { - Devel::Cover::Collection->new( - map { $_ => $Options->{$_} } qw( - bin_dir - docker - dryrun - force - local - modules - output_file - report - results_dir - timeout - verbose - workers - ) - ) + Devel::Cover::Collection->new( + map { $_ => $Options->{$_} } + qw( + bin_dir + docker + dryrun + force + local + modules + output_file + report + results_dir + timeout + verbose + workers + ) + ) } sub main { - # TODO - only one instance should run at a time - get_options; - - if ($Options->{latest}) { - my $cp = newcp; - $cp->get_latest; - return; - } - - if ($Options->{local_build}) { - my $cp = newcp; - $cp->set_modules(@ARGV); - $cp->local_build; - return; - } - - if ($Options->{module_file}) { - my $cp = newcp; - $cp->set_module_file($Options->{module_file}); - $cp->cover_modules; + # TODO - only one instance should run at a time + get_options; + + if ($Options->{latest}) { + my $cp = newcp; + $cp->get_latest; + return; + } + + if ($Options->{local_build}) { + my $cp = newcp; + $cp->set_modules(@ARGV); + $cp->local_build; + return; + } + + if ($Options->{module_file}) { + my $cp = newcp; + $cp->set_module_file($Options->{module_file}); + $cp->cover_modules; + } + + if ($Options->{build}) { + if (@ARGV) { + my $cp = newcp; + $cp->set_modules(@ARGV); + $cp->cover_modules; + } elsif (!-t STDIN) { + my @modules; + while (<>) { + chomp; + push @modules, split; + } + my $cp = newcp; + $cp->set_modules(@modules); + $cp->cover_modules; + } else { + my $cp = newcp; + $cp->cover_modules; } + } - if ($Options->{build}) { - if (@ARGV) { - my $cp = newcp; - $cp->set_modules(@ARGV); - $cp->cover_modules; - } elsif (! -t STDIN) { - my @modules; - while (<>) { - chomp; - push @modules, split; - } - my $cp = newcp; - $cp->set_modules(@modules); - $cp->cover_modules; - } else { - my $cp = newcp; - $cp->cover_modules; - } - } - - if ($Options->{generate_html}) { - my $cp = newcp; - $cp->generate_html; - } + if ($Options->{generate_html}) { + my $cp = newcp; + $cp->generate_html; + } - if ($Options->{compress_old_versions}) { - my $cp = newcp; - $cp->compress_old_versions($Options->{compress_old_versions}); - } + if ($Options->{compress_old_versions}) { + my $cp = newcp; + $cp->compress_old_versions($Options->{compress_old_versions}); + } } main @@ -156,16 +159,16 @@ cpancover - report coverage statistics on CPAN modules =head1 SYNOPSIS - cpancover -help -info -version - -collect -redo_cpancover_html -redo_html -force -dryrun - -modules module_name - -results_dir /path/to/dir - -outputdir /path/to/dir - -outputfile filename.html - -report report_name - -generate_html - -compress_old_versions number_to_keep - -local + cpancover -help -info -version + -collect -redo_cpancover_html -redo_html -force -dryrun + -modules module_name + -results_dir /path/to/dir + -outputdir /path/to/dir + -outputfile filename.html + -report report_name + -generate_html + -compress_old_versions number_to_keep + -local =head1 DESCRIPTION @@ -173,22 +176,22 @@ cpancover - report coverage statistics on CPAN modules The following command line options are supported: - -h -help - show help - -i -info - show documentation - -v -version - show version - -collect - collect coverage from modules (on) - -directory - location of the modules ($cwd) - -dryrun - don't execute (for some commands) (off) - -force - recollect coverage (off) - -modules - modules to use (all in $dir) - -outputdir - where to store output ($directory) - -outputfile - top level index (coverage.html) - -redo_cpancover_html - don't set default modules (off) - -redo_html - force html generation for modules (off) - -report - report to use (html_basic) - -generate_html - generate html (off) - -compress_old_versions - compress data older than n versions (3) - -local - use local (uninstalled) code (off) + -h -help - show help + -i -info - show documentation + -v -version - show version + -collect - collect coverage from modules (on) + -directory - location of the modules ($cwd) + -dryrun - don't execute (for some commands) (off) + -force - recollect coverage (off) + -modules - modules to use (all in $dir) + -outputdir - where to store output ($directory) + -outputfile - top level index (coverage.html) + -redo_cpancover_html - don't set default modules (off) + -redo_html - force html generation for modules (off) + -report - report to use (html_basic) + -generate_html - generate html (off) + -compress_old_versions - compress data older than n versions (3) + -local - use local (uninstalled) code (off) =head1 DETAILS @@ -202,17 +205,25 @@ The modules L