| 1 | package DDG::App::Attribution; | ||
| 2 | our $AUTHORITY = 'cpan:DDG'; | ||
| 3 | # ABSTRACT: Application class for reading the attributions of a package | ||
| 4 | $DDG::App::Attribution::VERSION = '1016'; | ||
| 5 | use MooX qw( | ||
| 6 | Options | ||
| 7 | ); | ||
| 8 | |||
| 9 | use Module::Runtime qw( use_module ); | ||
| 10 | use lib (); | ||
| 11 | use Path::Class; | ||
| 12 | |||
| 13 | sub BUILD { | ||
| 14 | my ( $self ) = @_; | ||
| 15 | my $curdir = dir('lib')->absolute; | ||
| 16 | lib->import($curdir->stringify); | ||
| 17 | my @modules = @ARGV ? @ARGV : (); # TODO get complete list of all available modules on no args | ||
| 18 | for (@modules) { | ||
| 19 | use_module($_); | ||
| 20 | if ($self->html) { | ||
| 21 | print $_->get_attributions_html; | ||
| 22 | print "\n"; | ||
| 23 | } else { | ||
| 24 | my @attributions = @{$_->get_attributions}; | ||
| 25 | if (@attributions) { | ||
| 26 | print "\nAttributions for ".$_.":\n\n"; | ||
| 27 | while (@attributions) { | ||
| 28 | my $key = shift @attributions; | ||
| 29 | my $value = shift @attributions; | ||
| 30 | print " - ".$key." (".$value.")\n"; | ||
| 31 | } | ||
| 32 | } else { | ||
| 33 | print "\nNo attributions for ".$_."\n\n"; | ||
| 34 | } | ||
| 35 | } | ||
| 36 | } | ||
| 37 | print "\n"; | ||
| 38 | } | ||
| 39 | |||
| 40 | option 'html' => ( | ||
| 41 | is => 'ro', | ||
| 42 | default => sub { 0 }, | ||
| 43 | negativable => 1, | ||
| 44 | ); | ||
| 45 | |||
| 46 | 1; | ||
| 47 | |||
| 48 | __END__ |