#!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; my @all_ct = $t->list_color_themes; my %all_ctobj; for my $ctname (@all_ct) { #say "D:$ctname"; my $info = instantiate_class_with_optional_args({ns_prefix=>"ColorTheme", construct=>0}, $ctname); my $class = $info->{class}; my $struct = $class->get_struct; my $args = ($struct->{examples} && @{ $struct->{examples} } ? $struct->{examples}[0]{args} : undef) // {}; $all_ctobj{$ctname} = instantiate_class_with_optional_args({}, [$class, $args]); } my $chosen_ct = $ARGV[0] // $t->color_theme; $t->columns(['Name', 'Summary']); for my $name (@all_ct) { my $ctobj = $all_ctobj{$name}; my $struct = $ctobj->get_struct; my $selected = $chosen_ct eq $name; $t->add_row([$name . ($selected ? " (*)" : ""), $struct->{summary}], {fgcolor=>($selected && $t->use_color ? 'aaaa00' : undef)}); } say "Tip: you can run me with color theme name as argument to try it out."; print $t->draw; $t = Text::ANSITable->new; $t->color_theme($chosen_ct); my $ct = $t->color_theme; $t->columns(['num','percent%','date','bool?','text']); $t->add_row([1, 0.4, time(), 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: List available color themes for Text::ANSITable # PODNAME: ansitable-list-color-themes __END__ =pod =encoding UTF-8 =head1 NAME ansitable-list-color-themes - List available color themes for Text::ANSITable =head1 VERSION This document describes version 0.610 of ansitable-list-color-themes (from Perl distribution Text-ANSITable), released on 2025-02-24. =head1 SYNOPSIS % ansitable-list-color-themes Sample output: Tip: you can run me with color theme name as argument to try it out. .------------------------------------------------------------------------------------------------------------------------------------------------------------------------. | Name Summary | | | | Data::Dump::Color::Default16 | | Data::Dump::Color::Default256 | | Data::Dump::Color::Light | | Distinct::WhiteBG Pick some distinct colors (that are suitable for white background) for you | | GraphicsColorNames Display Graphics::ColorNames::* color scheme as color theme | | Harmony::Analogous Create theme with colors equidistant in hue | | Harmony::Monochromatic Create a monochromatic color theme | | JSON::Color::bright256 A brighter color theme for 256-color terminal, adapted from the Data::Dump::Color::Default256 theme | | JSON::Color::default_ansi The default color theme for JSON::Color, using ANSI codes | | JSON::Color::default_rgb The default color theme for JSON::Color, using RGB color codes | | Lens::Darken Darken other theme | | Lens::Lighten Lighten other theme | | Lens::Tint Tint other theme | | NoColor (*) An empty color theme that provides no items | | Perinci::CmdLine::Classic::Default Default color theme for Perinci::CmdLine::Classic (for terminals with black background) | | Perinci::CmdLine::Classic::DefaultWhiteBG Default color theme for Perinci::CmdLine::Classic (for terminals with white background) | | Search::Light Light theme for text viewer/search application | | Test::Dynamic A dynamic color theme | | Test::RandomANSI16BG A color theme which gives random 16-color background ANSI codes | | Test::RandomANSI16FG A color theme which gives random 16-color foreground ANSI codes | | Test::RandomANSI16FGBG A color theme which gives random 16-color foreground+background ANSI codes | | Test::RandomANSI256BG A color theme which gives random 256-color background ANSI codes | | Test::RandomANSI256FG A color theme which gives random 256-color ANSI foreground codes | | Test::RandomANSI256FGBG A color theme which gives random 256-color background ANSI codes | | Test::RandomRGBBG A color theme which gives random RGB background colors | | Test::RandomRGBFG A color theme which gives random RGB foreground colors | | Test::RandomRGBFGBG A color theme which gives random RGB foreground+background colors | | Test::Static A static color theme | | Text::ANSITable::OldCompat::Default::default_gradation Gradation border (for terminal with black background) | | Text::ANSITable::OldCompat::Default::default_gradation_whitebg Gradation (for terminal with white background) | | Text::ANSITable::OldCompat::Default::default_nogradation No gradation, for black background | | Text::ANSITable::OldCompat::Default::default_nogradation_whitebg Default (no gradation, for white background) | | Text::ANSITable::OldCompat::Default::no_color An empty color theme that provides no items | | Text::ANSITable::Standard::Gradation Gradation border (for terminal with black background) | | Text::ANSITable::Standard::GradationWhiteBG Gradation (for terminal with white background) | | Text::ANSITable::Standard::NoGradation No gradation, for black background | | Text::ANSITable::Standard::NoGradationWhiteBG Default (no gradation, for white background) | `------------------------------------------------------------------------------------------------------------------------------------------------------------------------' Demo table .-------------------------------------------------------. | num percent% date bool? text | | | | 1 40.00% 2025-02-24 11:03:43 Y hello | | -3.3 100.00% 2025-02-24 11:03:43 N world | | | | 1 10.00% 2013-05-02 09:26:24 N x1 | | 2 20.00% 2013-05-02 12:13:04 Y x2 | | 3 30.00% 2013-05-02 14:59:44 Y x3 | | 4 40.00% 2013-05-02 17:46:24 Y x4 | | 5 50.00% 2013-05-02 20:33:04 Y x5 | `-------------------------------------------------------' =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