#!/usr/bin/perl

use 5.010;
use strict;
use warnings;

use Text::ANSITable;

our $VERSION = '0.04'; # VERSION

binmode(STDOUT, ":utf8");

my $t = Text::ANSITable->new;
my $all_ct = $t->list_color_themes(1);

$t->columns(['name', 'module', 'summary']);
for my $name (sort keys %$all_ct) {
    my $ct = $all_ct->{$name};
    $t->add_row([$name, $ct->{module}, $ct->{summary}],
                {fgcolor=>($ARGV[0] && $ARGV[0] eq $name ? 'aaaa00' : undef)});
}

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

if ($ARGV[0]) {
    require DateTime;

    $t = Text::ANSITable->new;
    $t->color_theme($ARGV[0]);
    my $ct = $t->color_theme;
    $t->columns(['num','percent%','date','bool?','text']);
    $t->add_row([1, 0.4, DateTime->now, 1, 'hello']);
    $t->add_row([-3.3, 1, time(), 0, 'world']);
    $t->add_row_separator;
    $t->add_row([$_, $_/10, 1367451584+$_*10000, int(rand()*2), "x$_"])
        for 1..5;

    say "Demo table";
    print $t->draw;
}
#ABSTRACT: Display a list of known color themes
#PODNAME: ansitable-list-color-themes

__END__
=pod

=encoding utf-8

=head1 NAME

ansitable-list-color-themes - Display a list of known color themes

=head1 VERSION

version 0.04

=head1 AUTHOR

Steven Haryanto <stevenharyanto@gmail.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Steven Haryanto.

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

=cut

