| 1 | #!/usr/bin/env perl | ||||||||||
| 2 | 7 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 7 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 7 | ▶ | use 5.010; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 7 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 7 | ▶ | use open ':std', ':encoding(UTF-8)'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 7 | ▶ | use Getopt::Long qw(:config posix_default no_ignore_case); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 7 | ▶ | use Pod::Usage; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 7 | ▶ | use FindBin; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 7 | ▶ | use lib "$FindBin::RealBin/../lib"; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 7 | ▶ | use Text::UnicodeStyle qw( stylize styles ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 7 | my $style = 'monospace'; | |||||||||
| 15 | 7 | my $help; | |||||||||
| 16 | my $list; | ||||||||||
| 17 | |||||||||||
| 18 | 7 | ▶ | GetOptions( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 'style|s=s' => \$style, | ||||||||||
| 20 | 'list|l' => \$list, | ||||||||||
| 21 | 'help|h|?' => \$help, | ||||||||||
| 22 | ) or pod2usage(2); | ||||||||||
| 23 | |||||||||||
| 24 | 7 | ▶ | pod2usage({ -verbose => 2, -exitval => 0 }) if $help; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | |||||||||||
| 26 | 4 | ▶ | if ($list) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 1 | say for styles(); | |||||||||
| 28 | 1 | exit 0; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 3 | my %known = map { $_ => 1 } styles(); | |||||||||
| 32 | pod2usage("Unknown style '$style'. Available: " . join(', ', styles())) | ||||||||||
| 33 | 3 | ▶ | unless $known{$style}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | |||||||||||
| 35 | 2 | my $text; | |||||||||
| 36 | 2 | ▶ | if (@ARGV) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 1 | $text = join ' ', @ARGV; | |||||||||
| 38 | } | ||||||||||
| 39 | else { | ||||||||||
| 40 | 1 | local $/; | |||||||||
| 41 | 1 | $text = <STDIN>; | |||||||||
| 42 | 1 | ▶ | defined $text or pod2usage(2); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 1 | $text =~ s/\s+\z//; | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 2 | say stylize($text, $style); | |||||||||
| 47 | |||||||||||
| 48 | __END__ | ||||||||||