NAME

App::Adenosine::Plugin::Rainbow

VERSION

version 2.002000

DESCRIPTION

Color codes standard error (diagnostics) from curl. Highly customizable.

METHODS

colorize

$p->colorize('red1', 'Christmas') . ' ' . $p->colorize('green1', 'tree!');

colorize is the method used to highlight all the pieces that come from the curl output. It takes two arguments, first a color specification, and next the string to be colorized. The complete color specification is defined as:

{
   fg         => $color,
   bg         => $color,
   bold       => $is_bold,
   italic     => $is_italic,
   underline  => $is_underline,
}

All of the keys in the hash are optional. The values for $color can be found at "Standard color map" in Term::ExtendedColor. Additionally I've added a form of "legacy support" for named 16 color mode. Those colors are actually arbitrary and most consoles allow you to redefine them, so the names I gave are just the defaults. My named colors are:

red
green
yellow
blue
purple
cyan
white
gray
bright_red
bright_green
bright_yellow
bright_blue
magenta
bright_cyan
bright_white

As a shortcut, if you pass a simple string instead of a hashref it wil be explanded to { fg => $str }.

Note that unfortunately support for all the attributes are spotty. For example on my computer I use tmux 1.6 running within terminator 0.96. In this situation I can't use any of the non-color attributes. Outside of tmux underline works, but the others do not. Similarly, bold only seems to work with some colors. It's pretty frustrating, and experimentation seems necesary.

Overriding colors at runtime

To change a color when you run adenosine instantiate it as follows:

#!/usr/bin/env perl

use lib 'path/to/adenosine/lib';
use App::Adenosine;

use App::Adenosine::Plugin::Rainbow;
App::Adenosine->new({
   argv => \@ARGV,
   plugins => [
      App::Adenosine::Plugin::Rainbow->new(
         response_header_name_color => 'orange4',
         response_header_value_color => 'orange2',
         response_ellided_body_color => {
            fg => 'blue12',
            bg => 'blue16',
         },
      ),
   ],
});

Creating custom themes

To create a custom theme just subclass Rainbow as follows:

package App::Adennosine::Plugin::Rainbow::Valentine;

use Moo;
extends 'App::Adenosine::Plugin::Rainbow';

has '+response_header_name_color'  => ( default => sub { 'magenta1'  } );
has '+response_header_value_color' => ( default => sub { 'magenta19' } );
has '+request_header_name_color'   => ( default => sub { 'magenta7'  } );
has '+request_header_value_color'  => ( default => sub { 'magenta25' } );

1;

Then use it the same way you use Rainbow:

...
App::Adenosine->new({ argv => \@ARGV, plugins => ['::Rainbow::Valentine'] })

COLORABLE SECTIONS

Rainbow splits apart the stderr string from curl and hilights the various sections respectively. The values of the sections are what is passed as the first argument to "colorize". The names of the sections are:

  • response_header_colon_color

  • response_header_name_color

  • response_header_value_color

  • request_header_colon_color

  • request_header_name_color

  • request_header_value_color

  • info_star_color

  • response_bracket_color

  • request_bracket_color

  • request_method_color

  • request_uri_color

  • request_protocol_color

  • request_protocol_version_color

  • response_protocol_color

  • response_protocol_version_color

  • response_status_code_color

  • response_status_text_color

  • response_ellided_bracket_color

  • response_ellided_body_color

  • request_ellided_bracket_color

  • request_ellided_body_color

AUTHOR

Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2018 by Arthur Axel "fREW" Schmidt.

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