| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use feature 'say'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use File::Basename; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use App::LinkSite; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 3 | my %opt; | |||||||||||||||||||||||||||
| 13 | 3 | ▶ | GetOptions(\%opt, 'help', 'version', 'file=s') or exit 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 3 | ▶ | if ($opt{help} || $opt{version}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opt{"help"} or $opt{"version"}
MC/DC0%0/2
$opt{"help"} or $opt{"version"}
$opt{"help"}
$opt{"version"}
Truth table33%1/3
A or B
A= $opt{"help"}B= $opt{"version"}
| |||||||||||||||||||||||||||||
| 16 | 0 | my $me = basename $0; | |||||||||||||||||||||||||||
| 17 | 0 | ▶ | if ($opt{version}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | 0 | say "$me $App::LinkSite::VERSION"; | |||||||||||||||||||||||||||
| 19 | 0 | ▶ | say '' if $opt{help}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | if ($opt{help}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 0 | say "Usage: $me [--file <filename>] [--help] [--version]"; | |||||||||||||||||||||||||||
| 24 | 0 | say "\nCreate a link site from a simple input file. See 'man $me' for details"; | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | exit; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 3 | ▶ | App::LinkSite->new(exists $opt{file} ? (file => $opt{file}) : ())->run; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =head1 linksite | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | Create a link site from a simple input file. | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | This program parses a JSON file (called C<links.json> by default) and turns the data | ||||||||||||||||||||||||||||
| 37 | into a link site (a bit like LinkTree). | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | linksite [--file <filename>] [--help] [--version] | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | =head1 OPTIONS | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | =over 4 | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | =item --file <filename> | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | Specify the path to the JSON file containing link data. Defaults to C<links.json>. | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =item --help | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | Display usage information. | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =item --version | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | Display the version number. | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =back | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =head1 EXIT STATUS | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | Returns zero after a successful build or an informational option. Invalid | ||||||||||||||||||||||||||||
| 64 | options, including C<--file> without a filename, return status 2 without building. | ||||||||||||||||||||||||||||
| 65 | Input or build failures return a non-zero status. | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | For more information see L<https://linksite.davecross.co.uk/>. | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =cut | ||||||||||||||||||||||||||||