]> Dogcows Code - chaz/git-codeowners/commitdiff
use Text::Table::Any for table formatting
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Sat, 9 Nov 2019 22:34:34 +0000 (15:34 -0700)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Sat, 9 Nov 2019 22:34:34 +0000 (15:34 -0700)
bin/git-codeowners
lib/App/Codeowners.pm

index d565192c139cbdab4874d539c34384418bb0a4f8..60e79b27bcd2a8d04b67ca38435c6f06fe718e68 100755 (executable)
@@ -104,12 +104,14 @@ The C<--format> argument can be one of:
 * C<csv> - Comma-separated values (requires L<Text::CSV>)
 * C<json:pretty> - Pretty JSON (requires L<JSON::MaybeXS>)
 * C<json> - JSON (requires L<JSON::MaybeXS>)
-* C<table> - Table (requires L<Text::Table>)
+* C<table> - Table (requires L<Text::Table::Any>)
 * C<tsv> - Tab-separated values (requires L<Text::CSV>)
 * C<yaml> - YAML (requires L<YAML>)
 * C<FORMAT> - Custom format (see below)
 
-You can specify a custom format using printf-like format sequences. These are the items that can
+=head2 Custom
+
+You can specify a custom format using printf-like format sequences. These are the items that can be
 substituted:
 
 =for :list
@@ -134,6 +136,16 @@ Available filters:
 * C<color:FFFFFF> - Colorize the replacement string (if color is ON).
 * C<nocolor> - Do not colorize replacement string.
 
+=head2 Table
+
+Table formatting can be done by one of several different modules, each with its own features and
+bugs. The default module is L<Text::Table::Tiny>, but this can be overridden using the
+C<PERL_TEXT_TABLE> environment variable if desired, like this:
+
+    PERL_TEXT_TABLE=Text::Table::HTML git-codeowners -f table
+
+The list of available modules is at L<Text::Table::Any/@BACKENDS>.
+
 =cut
 
 # FATPACK - Do not remove this line.
index efe86f7e88e428bb76108d78c17183300844b12e..113a3a10b4140daec443061731b8868258af9770 100644 (file)
@@ -174,11 +174,14 @@ sub _format {
     my $rows    = $args{rows}    || [];
 
     if ($format eq 'table') {
-        eval { require Text::Table } or die "Missing dependency: Text::Table\n";
+        eval { require Text::Table::Any } or die "Missing dependency: Text::Table::Any\n";
 
-        my $table = Text::Table->new(@$headers);
-        $table->load(map { [map { _stringify($_) } @$_] } @$rows);
-        print { $fh } encode('UTF-8', "$table");
+        my $table = Text::Table::Any::table(
+            header_row  => 1,
+            rows        => [$headers, map { [map { _stringify($_) } @$_] } @$rows],
+            backend     => $ENV{PERL_TEXT_TABLE},
+        );
+        print { $fh } encode('UTF-8', $table);
     }
     elsif ($format =~ /^json(:pretty)?$/) {
         my $pretty = !!$1;
This page took 0.026019 seconds and 4 git commands to generate.