X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=lib%2FApp%2FCodeowners%2FFormatter%2FTable.pm;fp=lib%2FApp%2FCodeowners%2FFormatter%2FTable.pm;h=1f9373e1e647d53e39053d31bf9bff17f7fb66a4;hb=26eed33eb4aa577d9347e5ebaf577b3e3a2c0396;hp=0000000000000000000000000000000000000000;hpb=f5bbfcbc345874483160d1cf8fb52871ab6a7d85;p=chaz%2Fgit-codeowners diff --git a/lib/App/Codeowners/Formatter/Table.pm b/lib/App/Codeowners/Formatter/Table.pm new file mode 100644 index 0000000..1f9373e --- /dev/null +++ b/lib/App/Codeowners/Formatter/Table.pm @@ -0,0 +1,34 @@ +package App::Codeowners::Formatter::Table; +# ABSTRACT: Format codeowners output as a table + +=head1 DESCRIPTION + +This is a L that formats output using L. + +=cut + +use warnings; +use strict; + +our $VERSION = '9999.999'; # VERSION + +use parent 'App::Codeowners::Formatter'; + +use App::Codeowners::Util qw(stringify); +use Encode qw(encode); + +sub finish { + my $self = shift; + my $results = shift; + + eval { require Text::Table::Any } or die "Missing dependency: Text::Table::Any\n"; + + my $table = Text::Table::Any::table( + header_row => 1, + rows => [$self->columns, map { [map { stringify($_) } @$_] } @$results], + backend => $ENV{PERL_TEXT_TABLE}, + ); + print { $self->handle } encode('UTF-8', $table); +} + +1;