App-chalk

 view release on metacpan or  search on metacpan

devscripts/bench  view on Meta::CPAN

    }
    die "Can't find node's chalk" unless $node_chalk;
}

Benchmark::Command::run(
    undef,
    {
        'perl (--help)' => [$^X, "$Bin/../bin/chalk", "--help"],
        'node (--help)' => [$node_chalk, "--help"],

        'perl (red bold str)' => [$^X, "$Bin/../bin/chalk", "red","bold","str"],
        'node (red bold str)' => [$node_chalk, "red", "bold", "str"],

        'perl (100_000 lines)' => sub {
            open my($fh), "| $^X $Bin/../bin/chalk red bold" or die $!;
            for (1..100_000) {
                print $fh "foo\n";
            }
            close $fh or die $!;
        },

        'node (100_000 lines)' => sub {
            open my($fh), "| $node_chalk red bold" or die $!;
            for (1..100_000) {
                print $fh "foo\n";
            }
            close $fh or die $!;
        },
    },
    {
        quiet => 1,
    },
);

script/chalk  view on Meta::CPAN

use Getopt::Long qw(:config gnu_getopt no_ignore_case);
BEGIN { require Win32::Console::ANSI if $^O eq 'MSWin32' }

our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2022-09-29'; # DATE
our $DIST = 'App-chalk'; # DIST
our $VERSION = '0.050'; # VERSION

my %CODES = (
    reset         => "\e[0m",
    bold          => "\e[1m",
    dim           => "\e[2m",
    italic        => "\e[3m",
    underline     => "\e[4m",
    inverse       => "\e[7m",
    hidden        => "\e[8m",
    strikethrough => "\e[9m",

    black   => "\e[30m",
    red     => "\e[31m",
    green   => "\e[32m",

script/chalk  view on Meta::CPAN


if ($opts{help}) {
    print <<'EOF';
chalk - Colorize text for terminal output

Usage:
  % chalk [options] <style> ... <string>
  % echo <string> | chalk [options] <style> ...

Example:
  % chalk red bold 'Unicorns & Rainbows'

Options:
  -n          Do not output the trailing newline
  --help, -h  Display help

EOF
    exit 0;
}

sub parse_styles {
    my $ansi = "";
    my $bold;
    for (@_) {
        $CODES{$_} or die "Invalid style: $_\n";
        $ansi .= $CODES{$_};
    }
    $ansi;
}

my $in_interactive  = (-t STDIN); ## no critic: InputOutput::ProhibitInteractiveTest
my $out_interactive = (-t STDOUT); ## no critic: InputOutput::ProhibitInteractiveTest
my $supports_color  = $ENV{FORCE_COLOR} ? 1 :

script/chalk  view on Meta::CPAN


=head1 SYNOPSIS

Usage:

 % chalk [options] <style> ... <string>
 % echo <string> | chalk [options] <style> ...

Example:

 % chalk red bold 'Unicorns & Rainbows'

=head1 DESCRIPTION

This is a Perl port of node.js' chalk-cli utility
(L<https://www.npmjs.com/package/chalk-cli>). This Perl port is basically the
same as the node.js' version, but with a smaller startup overhead.

=head1 OPTIONS

=head2 --help, -h

script/chalk  view on Meta::CPAN


Do not output the trailing newline.

=head1 FAQ

=head2 What are the supported styles?

Modifiers:

    reset
    bold
    dim
    italic (not widely supported)
    underline
    inverse
    hidden
    strikethrough (not widely supported)

Colors:

    black



( run in 0.501 second using v1.01-cache-2.11-cpan-5dc5da66d9d )