File Coverage

bin/pod2asciidoctor
Criterion Covered Total %
statement 36 38 94.7
branch 3 6 50.0
condition n/a
subroutine 9 9 100.0
pod n/a
total 48 53 90.5


line stmt bran cond sub pod time code
1             #! /usr/bin/env perl
2             #
3             # Short description for pod2asciidoctor.pl
4             #
5             # Version 0.0.1
6             # Copyright (C) 2023 Shlomi Fish < https://www.shlomifish.org/ >
7             #
8             # Licensed under the terms of the MIT license.
9              
10 1     1   5604 use strict;
  1         2  
  1         43  
11 1     1   5 use warnings;
  1         2  
  1         85  
12 1     1   24 use 5.014;
  1         3  
13 1     1   974 use autodie;
  1         24947  
  1         4  
14              
15 1     1   8679 use Carp qw/ confess /;
  1         3  
  1         84  
16 1     1   1037 use Getopt::Long qw/ GetOptions /;
  1         19982  
  1         7  
17 1     1   1228 use Path::Tiny qw/ cwd path tempdir tempfile /;
  1         18439  
  1         131  
18              
19 1     1   697 use Pod::AsciiDoctor ();
  1         3  
  1         295  
20              
21             sub run
22             {
23 1     1   30 my $output_fn;
24              
25 1 50       6 GetOptions( "output|o=s" => \$output_fn, )
26             or die "error in cmdline args: $!";
27              
28 1 50       1038 if ( !defined($output_fn) )
29             {
30 0         0 die "Output filename not specified! Use the -o|--output flag!";
31             }
32 1         38 my $adoc = Pod::AsciiDoctor->new();
33 1         3 my $in_filename = shift(@ARGV);
34 1         5 my $in_fh = path( $in_filename, );
35 1         85 my $in = $in_fh->openr_utf8();
36 1         2387 $adoc->parse_from_filehandle($in);
37 1         21 my $USE_STDOUT = ( $output_fn eq '-' );
38 1 50       5 if ($USE_STDOUT)
39             {
40 0         0 print $adoc->adoc();
41             }
42             else
43             {
44 1         6 path($output_fn)->spew_utf8( $adoc->adoc() );
45             }
46              
47 1           exit(0);
48             }
49              
50 1         406080 run();
51              
52             1;
53              
54             __END__