#!perl

use 5.010001;
use strict;
use warnings;

use Module::Load::Util qw(instantiate_class_with_optional_args);
use Text::ANSITable;

our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2025-02-24'; # DATE
our $DIST = 'Text-ANSITable'; # DIST
our $VERSION = '0.610'; # VERSION

binmode(STDOUT, ":encoding(utf8)");

my $t = Text::ANSITable->new;

if ($ARGV[0]) {
    $t->border_style($ARGV[0]);
}

my @all_bs = $t->list_border_styles;
my %all_bsobj;
for my $bsname (@all_bs) {
    my $info = instantiate_class_with_optional_args({ns_prefix=>"BorderStyle", construct=>0}, $bsname);
    my $class = $info->{class};
    my $struct = $class->get_struct;
    my $args = ($struct->{examples} && @{ $struct->{examples} } ? $struct->{examples}[0]{args} : undef) // {};
    $all_bsobj{$bsname} = instantiate_class_with_optional_args({}, [$class, $args]);
}

$t->columns(['Name', 'Summary', 'box_chars?', 'utf8?']);
my $utf8; # we sort by not utf8 and then utf8, just to demonstrate add_row_separator
for my $name (sort {($all_bsobj{$a}->get_struct->{utf8} ? 1:0)<=>($all_bsobj{$b}->get_struct->{utf8} ? 1:0) || $a cmp $b} @all_bs) {
    my $bsobj = $all_bsobj{$name};
    my $struct = $bsobj->get_struct;
    my $selected = $name eq $t->border_style;
    $t->add_row(
        [$name . ($selected ? " (*)" : ""), $struct->{summary}, $struct->{box_chars} ? 1:0, $struct->{utf8} ? 1:0],
        {fgcolor=>$selected && $t->use_color ? "aaaa00" : undef});

    if (!$utf8 && $struct->{utf8}) {
        $t->add_row_separator;
        $utf8++;
    }
}

say "Tip: you can run me with border style name as argument to try it out.";
print $t->draw;

#use Data::Dump; dd $t->{_row_separators}; dd $t->{_draw}{frow_separators};

# ABSTRACT: List available border styles for Text::ANSITable
# PODNAME: ansitable-list-border-styles

__END__

=pod

=encoding UTF-8

=head1 NAME

ansitable-list-border-styles - List available border styles for Text::ANSITable

=head1 VERSION

This document describes version 0.610 of ansitable-list-border-styles (from Perl distribution Text-ANSITable), released on 2025-02-24.

=head1 SYNOPSIS

 % ansitable-list-border-styles

Sample output:

 Tip: you can run me with border style name as argument to try it out.
 .-------------------------------------------------------------------------------------------------------------------------------------------------------------------------.
 | Name                                       Summary                                                                                                   box_chars?   utf8? |
 |                                                                                                                                                                         |
 | ASCII::None                                No borders, but row separator is still drawn using dashes                                                     N          N   |
 | ASCII::SingleLine                          Single line border with ASCII characters                                                                      N          N   |
 | ASCII::SingleLineDoubleAfterHeader         Just like ASCII::SingleLine but uses double line to separate header row and first data row                    N          N   |
 | ASCII::SingleLineHorizontalOnly            Single line border with ASCII characters, horizontal only                                                     N          N   |
 | ASCII::SingleLineInnerOnly                 Single line border with ASCII characters, between columns only                                                N          N   |
 | ASCII::SingleLineOuterOnly (*)             Single line border with ASCII characters, outer borders only                                                  N          N   |
 | ASCII::SingleLineVerticalOnly              Single line border with ASCII characters, vertical only                                                       N          N   |
 | ASCII::Space                               Space as borders, but data row separator is still drawn using dashes                                          N          N   |
 | ASCII::SpaceInnerOnly                      No borders, but columns are still separated using spaces and data row separator is still drawn using          N          N   |
 |                                            dashes                                                                                                                       |
 | BoxChar::None                              No borders, but data row separator is still drawn using horizontal line                                       Y          N   |
 | BoxChar::SingleLine                        Single line border with box-drawing characters                                                                Y          N   |
 | BoxChar::SingleLineHorizontalOnly          Single line border with box-drawing characters, horizontal only                                               Y          N   |
 | BoxChar::SingleLineInnerOnly               Single line border with box-drawing characters, between columns only                                          Y          N   |
 | BoxChar::SingleLineOuterOnly               Single line border with box-drawing characters, outer borders only                                            Y          N   |
 | BoxChar::SingleLineVerticalOnly            Single line border with box-drawing characters, vertical only                                                 Y          N   |
 | BoxChar::Space                             Space as borders, but data row separator is still drawn using horizontal line                                 Y          N   |
 | BoxChar::SpaceInnerOnly                    No borders, but columns are still separated using spaces and data row separator is still drawn using          Y          N   |
 |                                            horizontal line                                                                                                              |
 | Test::CustomChar                           A border style that uses a single custom character                                                            N          N   |
 | Test::Random                               A border style that uses random characters                                                                    N          N   |
 | Text::ANSITable::OldCompat::Default::non   No borders, but row separator is still drawn using dashes                                                     N          N   |
 | e_ascii                                                                                                                                                                 |
 | Text::ANSITable::OldCompat::Default::non   No borders, but data row separator is still drawn using horizontal line                                       Y          N   |
 | e_boxchar                                                                                                                                                               |
 | Text::ANSITable::OldCompat::Default::sin   Single line border with ASCII characters                                                                      N          N   |
 | gle_ascii                                                                                                                                                               |
 | Text::ANSITable::OldCompat::Default::sin   Single line border with box-drawing characters                                                                Y          N   |
 | gle_boxchar                                                                                                                                                             |
 | Text::ANSITable::OldCompat::Default::sin   Single line border with ASCII characters, horizontal only                                                     N          N   |
 | gleh_ascii                                                                                                                                                              |
 | Text::ANSITable::OldCompat::Default::sin   Single line border with box-drawing characters, horizontal only                                               Y          N   |
 | gleh_boxchar                                                                                                                                                            |
 | Text::ANSITable::OldCompat::Default::sin   Single line border with ASCII characters, between columns only                                                N          N   |
 | glei_ascii                                                                                                                                                              |
 | Text::ANSITable::OldCompat::Default::sin   Single line border with box-drawing characters, between columns only                                          Y          N   |
 | glei_boxchar                                                                                                                                                            |
 | Text::ANSITable::OldCompat::Default::sin   Single line border with ASCII characters, outer borders only                                                  N          N   |
 | gleo_ascii                                                                                                                                                              |
 | Text::ANSITable::OldCompat::Default::sin   Single line border with box-drawing characters, outer borders only                                            Y          N   |
 | gleo_boxchar                                                                                                                                                            |
 | Text::ANSITable::OldCompat::Default::sin   Single line border with ASCII characters, vertical only                                                       N          N   |
 | glev_ascii                                                                                                                                                              |
 | Text::ANSITable::OldCompat::Default::sin   Single line border with box-drawing characters, vertical only                                                 Y          N   |
 | glev_boxchar                                                                                                                                                            |
 | Text::ANSITable::OldCompat::Default::spa   Space as borders, but data row separator is still drawn using dashes                                          N          N   |
 | ce_ascii                                                                                                                                                                |
 | Text::ANSITable::OldCompat::Default::spa   Space as borders, but data row separator is still drawn using horizontal line                                 Y          N   |
 | ce_boxchar                                                                                                                                                              |
 | Text::ANSITable::OldCompat::Default::spa   No borders, but columns are still separated using spaces and data row separator is still drawn using          N          N   |
 | cei_ascii                                  dashes                                                                                                                       |
 | Text::ANSITable::OldCompat::Default::spa   No borders, but columns are still separated using spaces and data row separator is still drawn using          Y          N   |
 | cei_boxchar                                horizontal line                                                                                                              |
 | Test::Labeled                              A border style that uses labeled characters                                                                   N          Y   |
 |                                                                                                                                                                         |
 | Text::ANSITable::OldCompat::Default::bol   Bold single-line border with UTF8 characters                                                                  N          Y   |
 | d                                                                                                                                                                       |
 | Text::ANSITable::OldCompat::Default::bri   Single-line, bold on bottom right to give illusion of depth                                                   N          Y   |
 | ck                                                                                                                                                                      |
 | Text::ANSITable::OldCompat::Default::bri   Single-line (outer only), bold on bottom right to give illusion of depth                                      N          Y   |
 | cko                                                                                                                                                                     |
 | Text::ANSITable::OldCompat::Default::csi   Single-line border with UTF8 characters, curved edges                                                         N          Y   |
 | ngle                                                                                                                                                                    |
 | Text::ANSITable::OldCompat::Default::dou   Double-line border with UTF8 characters                                                                       N          Y   |
 | ble                                                                                                                                                                     |
 | Text::ANSITable::OldCompat::Default::non   No borders, but data row separator is still drawn using horizontal line                                       N          Y   |
 | e_utf8                                                                                                                                                                  |
 | Text::ANSITable::OldCompat::Default::sin   Single-line border with UTF8 characters                                                                       N          Y   |
 | gle_utf8                                                                                                                                                                |
 | Text::ANSITable::OldCompat::Default::sin   Single line border with box-drawing characters, horizontal only                                               N          Y   |
 | gleh_utf8                                                                                                                                                               |
 | Text::ANSITable::OldCompat::Default::sin   Single line border with UTF8 characters, between columns only                                                 N          Y   |
 | glei_utf8                                                                                                                                                               |
 | Text::ANSITable::OldCompat::Default::sin   Single line border with UTF8 characters, outer borders only                                                   N          Y   |
 | gleo_utf8                                                                                                                                                               |
 | Text::ANSITable::OldCompat::Default::sin   Single line border with UTF8 characters, vertical only                                                        N          Y   |
 | glev_utf8                                                                                                                                                               |
 | Text::ANSITable::OldCompat::Default::spa   Space as borders, but data row separator is still drawn using horizontal line                                 N          Y   |
 | ce_utf8                                                                                                                                                                 |
 | Text::ANSITable::OldCompat::Default::spa   No borders, but columns are still separated using spaces and data row separator is still drawn using          N          Y   |
 | cei_utf8                                   horizontal line                                                                                                              |
 | UTF8::Brick                                Single-line, bold on bottom right to give illusion of depth                                                   N          Y   |
 | UTF8::BrickOuterOnly                       Single-line (outer only), bold on bottom right to give illusion of depth                                      N          Y   |
 | UTF8::DoubleLine                           Double-line border with UTF8 characters                                                                       N          Y   |
 | UTF8::None                                 No borders, but data row separator is still drawn using horizontal line                                       N          Y   |
 | UTF8::SingleLine                           Single-line border with UTF8 characters                                                                       N          Y   |
 | UTF8::SingleLineBold                       Bold single-line border with UTF8 characters                                                                  N          Y   |
 | UTF8::SingleLineBoldHeader                 Single-line border (header box bold) with UTF8 characters                                                     N          Y   |
 | UTF8::SingleLineCurved                     Single-line border with UTF8 characters, curved edges                                                         N          Y   |
 | UTF8::SingleLineDoubleAfterHeader          Just like UTF8::SingleLine but uses double line to separate header row and first data row                     N          Y   |
 | UTF8::SingleLineHorizontalOnly             Single line border with box-drawing characters, horizontal only                                               N          Y   |
 | UTF8::SingleLineInnerOnly                  Single line border with UTF8 characters, between columns only                                                 N          Y   |
 | UTF8::SingleLineOuterOnly                  Single line border with UTF8 characters, outer borders only                                                   N          Y   |
 | UTF8::SingleLineVerticalOnly               Single line border with UTF8 characters, vertical only                                                        N          Y   |
 | UTF8::Space                                Space as borders, but data row separator is still drawn using horizontal line                                 N          Y   |
 | UTF8::SpaceInnerOnly                       No borders, but columns are still separated using spaces and data row separator is still drawn using          N          Y   |
 |                                            horizontal line                                                                                                              |
 `-------------------------------------------------------------------------------------------------------------------------------------------------------------------------'

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/Text-ANSITable>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-Text-ANSITable>.

=head1 AUTHOR

perlancar <perlancar@cpan.org>

=head1 CONTRIBUTING


To contribute, you can send patches by email/via RT, or send pull requests on
GitHub.

Most of the time, you don't need to build the distribution yourself. You can
simply modify the code, then test via:

 % prove -l

If you want to build the distribution (e.g. to try to install it locally on your
system), you can install L<Dist::Zilla>,
L<Dist::Zilla::PluginBundle::Author::PERLANCAR>,
L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond
that are considered a bug and can be reported to me.

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2025 by perlancar <perlancar@cpan.org>.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Text-ANSITable>

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.

=cut