bin/z85_convert

filter: Statementstmt 94.4% 34 / 36 Branchbran 83.3% 10 / 12 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 83.3% 5 / 6 Podpod n/a totaltotal 85.9% 49 / 57 CC 2 SCAR 8.9
CC
2
Cov
88%
__ANON__
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
« blib/lib/Convert/Z85.pm ↑ Summary
1 #!perl
2  
3 6 ▶use strict; use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 6 ▶use Convert::Z85;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 6 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 my $do_decode = 0;
9 6 my $wrap = 0;
10 6 my $file;
11 GetOptions(
12 0 ▶ version => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
13 0 ▶ print
Condition0%0/2
$Convert::Z85::VERSION || '(git)'
l!l
00
MC/DC0%0/1
$Convert::Z85::VERSION || '(git)'
$Convert::Z85::VERSION
Truth table0%0/2
A
A= $Convert::Z85::VERSION
Aresult
11
00
14 "z85_convert - Convert::Z85 - ",
15 ($Convert::Z85::VERSION || '(git)'),
16 "\n"
17 ;
18 0 exit 0
19 },
20  
21 1 ▶ help => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
22 1 print
23 "z85_convert - encode or decode data or Z85 text\n\n",
24 " --file=FILE Retrieve input from FILE (rather than STDIN)\n",
25 " --decode Decode Z85 text (rather than encoding data)\n",
26 " --wrap=COLS Wrap encoded lines after COLS characters\n",
27 "\n"
28 ;
29 1 exit 0
30 },
31  
32 6 decode => \$do_decode,
33 'file=s' => \$file,
34 'wrap=i' => \$wrap,
35 );
36 5 ▶$file = shift @ARGV unless $file;
Branch: 1 branch
BranchTrueFalseTotal
unless $file 4 1 5
37  
38 5 my $input;
39 5 ▶if ($file) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file) { } 3 2 5
40 3 ▶ open my $fh, $file or die $!;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, $file or die $! 3 0 3
41 3 $input = do { local $/; <$fh> };
42 3 ▶ close $fh or warn $!;
Branch: 1 branch
BranchTrueFalseTotal
close $fh or warn $! 3 0 3
43 } else {
44 2 $input = do { local $/; <STDIN> };
45 }
46  
47 5 ▶if ($do_decode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($do_decode) { } 2 3 5
48 # accept extraneous newlines in z85 stream ->
49 2 print decode_z85(join('', split /\n/, $input), pad => 1)
50 } else {
51 3 my $output = encode_z85($input, pad => 1);
52 3 ▶ $output = join "\n", unpack "(A$wrap)*", $output if $wrap;
Branch: 1 branch
BranchTrueFalseTotal
if $wrap 1 2 3
53 3 print $output, "\n"
54 }
55  
56 =pod
57  
58 =head1 NAME
59  
60 z85_convert - Command line interface to Convert::Z85
61  
62 =head1 SYNOPSIS
63  
64 # Encode Z85 from file:
65 sh$ z85_convert --file FILE
66  
67 # Decode Z85 from file:
68 sh$ z85_convert --decode --file FILE
69
70 # Encode Z85 from STDIN (and wrap at 76 columns):
71 sh$ cat FILE | z85_convert -w 76
72  
73 =head1 DESCRIPTION
74  
75 A trivial command line interface to the Z85 encoding, as implemented by
76 L<Convert::Z85>.
77  
78 Padding is applied automatically.
79  
80 =head1 OPTIONS
81  
82 =head2 decode
83  
84 Decode, rather than encode, the given input.
85  
86 =head2 file
87  
88 A file path to encode or L</decode>.
89  
90 If none is specified, C<STDIN> is taken as input instead.
91  
92 =head1 AUTHOR
93  
94 Jon Portnoy <avenj@cobaltirc.org>
95  
96 =cut
« blib/lib/Convert/Z85.pm ↑ Summary