App-GitGot

 view release on metacpan or  search on metacpan

lib/App/GitGot/Outputter.pm  view on Meta::CPAN

package App::GitGot::Outputter;
our $AUTHORITY = 'cpan:GENEHACK';
$App::GitGot::Outputter::VERSION = '1.339';
# ABSTRACT: Generic base class for outputting formatted messages.
use 5.014;

use Term::ANSIColor qw/ colored /;
use Types::Standard -types;

use App::GitGot::Types;

use Moo;
use namespace::autoclean;


has no_color => (
  is            => 'ro' ,
  isa           => Bool ,
  default       => 0 ,
  documentation => 'boolean indicating whether color messages should be output at all' ,
);


sub error {
  my( $self , $message ) = @_;
  return $self->_colored( $message , $self->color_error );
}


sub major_change {
  my( $self , $message ) = @_;
  return $self->_colored( $message , $self->color_major_change );
}


sub minor_change {
  my( $self , $message ) = @_;
  return $self->_colored( $message , $self->color_minor_change );
}


sub warning {
  my( $self , $message ) = @_;
  return $self->_colored( $message , $self->color_warning );
}

sub _colored {
  my( $self , $message , $color_string ) = @_;

  return ( $self->no_color || $color_string eq 'uncolored' ) ? $message
    : colored( $message , $color_string );
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::GitGot::Outputter - Generic base class for outputting formatted messages.

=head1 VERSION

version 1.339

=head1 ATTRIBUTES

=head2 no_color



( run in 0.815 second using v1.01-cache-2.11-cpan-f56aa216473 )