| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||
| 2 | 44 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 44 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 44 | ▶ | use Text::Trac (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 44 | ▶ | use Getopt::Long qw(GetOptions); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 44 | ▶ | use Path::Tiny qw(path); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 44 | my ($infile, $outfile); | |||||||||||||||||||||||||||
| 10 | 44 | my $url = ''; | |||||||||||||||||||||||||||
| 11 | 44 | my $class; | |||||||||||||||||||||||||||
| 12 | my $span; | ||||||||||||||||||||||||||||
| 13 | 44 | my $id; | |||||||||||||||||||||||||||
| 14 | 44 | my $force; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 44 | ▶ | GetOptions( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | 'infile=s' => \$infile, | ||||||||||||||||||||||||||||
| 18 | 'outfile=s' => \$outfile, | ||||||||||||||||||||||||||||
| 19 | 'url=s' => \$url, | ||||||||||||||||||||||||||||
| 20 | 'class' => \$class, | ||||||||||||||||||||||||||||
| 21 | 'span' => \$span, | ||||||||||||||||||||||||||||
| 22 | 'id' => \$id, | ||||||||||||||||||||||||||||
| 23 | 'force' => \$force, | ||||||||||||||||||||||||||||
| 24 | ) or usage(); | ||||||||||||||||||||||||||||
| 25 | 44 | ▶ | usage() if not $infile or not $outfile; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$infile and $outfile
MC/DC50%1/2
$infile and $outfile
$infile
$outfile
Truth table66%2/3
A and B
A= $infileB= $outfile
| |||||||||||||||||||||||||||||
| 26 | 40 | ▶ | die "Infile '$infile' does not exist.\n" if not -e $infile; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 40 | ▶ | die "Outfile '$outfile' already exists.\n" if -e $outfile and not $force; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-e $outfile and not $force
MC/DC0%0/2
-e $outfile and not $force
-e $outfile
not $force
Truth table33%1/3
A and not(B)
A= -e $outfileB= not $force
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 40 | main(); | |||||||||||||||||||||||||||
| 30 | 40 | exit; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | sub main { | ||||||||||||||||||||||||||||
| 34 | 40 | ▶ | my $parser = Text::Trac->new( | ||||||||||||||||||||||||||
|
Subroutine
main: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | trac_url => $url, | ||||||||||||||||||||||||||||
| 36 | class => $class, | ||||||||||||||||||||||||||||
| 37 | span => $span, | ||||||||||||||||||||||||||||
| 38 | id => $id, | ||||||||||||||||||||||||||||
| 39 | # disable_links => [ qw( changeset ticket ) ], | ||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||
| 41 | 40 | $parser->parse( path($infile)->slurp_utf8 ); | |||||||||||||||||||||||||||
| 42 | 40 | path($outfile)->spew_utf8( $parser->html ); | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | sub usage { | ||||||||||||||||||||||||||||
| 47 | 4 | ▶ | print <<"END_USAGE"; | ||||||||||||||||||||||||||
|
Subroutine
usage: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 48 | Usage: $0 | ||||||||||||||||||||||||||||
| 49 | --infile filename (File in Trac wiki format) | ||||||||||||||||||||||||||||
| 50 | --outfile filename (The html file to generate) | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | --url http://... () | ||||||||||||||||||||||||||||
| 53 | --class Include class="" in the HTML tags. | ||||||||||||||||||||||||||||
| 54 | --span Include <span></span> | ||||||||||||||||||||||||||||
| 55 | --id Include id="" in the HTML tags. | ||||||||||||||||||||||||||||
| 56 | --force Overwrite exisiting html file. | ||||||||||||||||||||||||||||
| 57 | END_USAGE | ||||||||||||||||||||||||||||
| 58 | 4 | exit; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||