Blame README

Packit 158411
NAME
Packit 158411
Packit 158411
    Term::Table - Format a header and rows into a table
Packit 158411
Packit 158411
DESCRIPTION
Packit 158411
Packit 158411
    This is used by some failing tests to provide diagnostics about what
Packit 158411
    has gone wrong. This module is able to generic format rows of data into
Packit 158411
    tables.
Packit 158411
Packit 158411
SYNOPSIS
Packit 158411
Packit 158411
        use Term::Table;
Packit 158411
    
Packit 158411
        my $table = Term::Table->new(
Packit 158411
            max_width    => 80, # defaults to terminal size 
Packit 158411
            collapse     => 1, # do not show empty columns
Packit 158411
            header => [ 'name', 'age', 'hair color' ],
Packit 158411
            rows         => [
Packit 158411
                [ 'Fred Flinstone',  2000000, 'black' ],
Packit 158411
                [ 'Wilma Flinstone', 1999995, 'red' ],
Packit 158411
                ...
Packit 158411
            ],
Packit 158411
        );
Packit 158411
    
Packit 158411
        say $_ for $table->render;
Packit 158411
Packit 158411
    This prints a table like this:
Packit 158411
Packit 158411
        +-----------------+---------+------------+
Packit 158411
        | name            | age     | hair color |
Packit 158411
        +-----------------+---------+------------+
Packit 158411
        | Fred Flinstone  | 2000000 | black      |
Packit 158411
        | Wilma Flinstone | 1999995 | red        |
Packit 158411
        | ...             | ...     | ...        |
Packit 158411
        +-----------------+---------+------------+
Packit 158411
Packit 158411
INTERFACE
Packit 158411
Packit 158411
        use Term::Table;
Packit 158411
        my $table = Term::Table->new(...);
Packit 158411
Packit 158411
 OPTIONS
Packit 158411
Packit 158411
    header => [ ... ]
Packit 158411
Packit 158411
      If you want a header specify it here. This takes an arrayref with
Packit 158411
      each columns heading.
Packit 158411
Packit 158411
    rows => [ [...], [...], ... ]
Packit 158411
Packit 158411
      This should be an arrayref containing an arrayref per row.
Packit 158411
Packit 158411
    collapse => $bool
Packit 158411
Packit 158411
      Use this if you want to hide empty columns, that is any column that
Packit 158411
      has no data in any row. Having a header for the column will not
Packit 158411
      effect collapse.
Packit 158411
Packit 158411
    max_width => $num
Packit 158411
Packit 158411
      Set the maximum width of the table, the table may not be this big,
Packit 158411
      but it will be no bigger. If none is specified it will attempt to
Packit 158411
      find the width of your terminal and use that, otherwise it falls back
Packit 158411
      to the terminal width or 80.
Packit 158411
Packit 158411
    sanitize => $bool
Packit 158411
Packit 158411
      This will sanitize all the data in the table such that newlines,
Packit 158411
      control characters, and all whitespace except for ASCII 20 ' ' are
Packit 158411
      replaced with escape sequences. This prevents newlines, tabs, and
Packit 158411
      similar whitespace from disrupting the table.
Packit 158411
Packit 158411
      Note: newlines are marked as '\n', but a newline is also inserted
Packit 158411
      into the data so that it typically displays in a way that is useful
Packit 158411
      to humans.
Packit 158411
Packit 158411
      Example:
Packit 158411
Packit 158411
          my $field = "foo\nbar\nbaz\n";
Packit 158411
      
Packit 158411
          print join "\n" => table(
Packit 158411
              sanitize => 1,
Packit 158411
              rows => [
Packit 158411
                  [$field,      'col2'     ],
Packit 158411
                  ['row2 col1', 'row2 col2']
Packit 158411
              ]
Packit 158411
          );
Packit 158411
Packit 158411
      Prints:
Packit 158411
Packit 158411
          +-----------------+-----------+
Packit 158411
          | foo\n           | col2      |
Packit 158411
          | bar\n           |           |
Packit 158411
          | baz\n           |           |
Packit 158411
          |                 |           |
Packit 158411
          | row2 col1       | row2 col2 |
Packit 158411
          +-----------------+-----------+
Packit 158411
Packit 158411
      So it marks the newlines by inserting the escape sequence, but it
Packit 158411
      also shows the data across as many lines as it would normally
Packit 158411
      display.
Packit 158411
Packit 158411
    mark_tail => $bool
Packit 158411
Packit 158411
      This will replace the last whitespace character of any trailing
Packit 158411
      whitespace with its escape sequence. This makes it easier to notice
Packit 158411
      trailing whitespace when comparing values.
Packit 158411
Packit 158411
    show_header => $bool
Packit 158411
Packit 158411
      Set this to false to hide the header. This defaults to true if the
Packit 158411
      header is set, false if no header is provided.
Packit 158411
Packit 158411
    auto_columns => $bool
Packit 158411
Packit 158411
      Set this to true to automatically add columns that are not named in
Packit 158411
      the header. This defaults to false if a header is provided, and
Packit 158411
      defaults to true when there is no header.
Packit 158411
Packit 158411
    no_collapse => [ $col_num_a, $col_num_b, ... ]
Packit 158411
Packit 158411
    no_collapse => [ $col_name_a, $col_name_b, ... ]
Packit 158411
Packit 158411
    no_collapse => { $col_num_a => 1, $col_num_b => 1, ... }
Packit 158411
Packit 158411
    no_collapse => { $col_name_a => 1, $col_name_b => 1, ... }
Packit 158411
Packit 158411
      Specify (by number and/or name) columns that should not be removed
Packit 158411
      when empty. The 'name' form only works when a header is specified.
Packit 158411
      There is currently no protection to insure that names you specify are
Packit 158411
      actually in the header, invalid names are ignored, patches to fix
Packit 158411
      this will be happily accepted.
Packit 158411
Packit 158411
NOTE ON UNICODE/WIDE CHARACTERS
Packit 158411
Packit 158411
    Some unicode characters, such as 婧 (U+5A67) are wider than others.
Packit 158411
    These will render just fine if you use utf8; as necessary, and
Packit 158411
    Unicode::GCString is installed, however if the module is not installed
Packit 158411
    there will be anomalies in the table:
Packit 158411
Packit 158411
        +-----+-----+---+
Packit 158411
        | a   | b   | c |
Packit 158411
        +-----+-----+---+
Packit 158411
        | 婧 | x   | y |
Packit 158411
        | x   | y   | z |
Packit 158411
        | x   | 婧 | z |
Packit 158411
        +-----+-----+---+
Packit 158411
Packit 158411
SOURCE
Packit 158411
Packit 158411
    The source code repository for Term-Table can be found at
Packit 158411
    http://github.com/exodist/Term-Table/.
Packit 158411
Packit 158411
MAINTAINERS
Packit 158411
Packit 158411
    Chad Granum <exodist@cpan.org>
Packit 158411
Packit 158411
AUTHORS
Packit 158411
Packit 158411
    Chad Granum <exodist@cpan.org>
Packit 158411
Packit 158411
COPYRIGHT
Packit 158411
Packit 158411
    Copyright 2016 Chad Granum <exodist@cpan.org>.
Packit 158411
Packit 158411
    This program is free software; you can redistribute it and/or modify it
Packit 158411
    under the same terms as Perl itself.
Packit 158411
Packit 158411
    See http://dev.perl.org/licenses/
Packit 158411