#!/usr/bin/env perl

use strict;
use warnings;
use feature 'say';

use Getopt::Long;
use File::Basename;

use App::LinkSite;

my %opt;
GetOptions(\%opt, 'help', 'version', 'file=s') or exit 2;

if ($opt{help} || $opt{version}) {
  my $me = basename $0;
  if ($opt{version}) {
    say "$me $App::LinkSite::VERSION";
    say '' if $opt{help};
  }

  if ($opt{help}) {
    say "Usage: $me [--file <filename>] [--help] [--version]";
    say "\nCreate a link site from a simple input file. See 'man $me' for details";
  }

  exit;
}

App::LinkSite->new(exists $opt{file} ? (file => $opt{file}) : ())->run;

=head1 linksite

Create a link site from a simple input file.

This program parses a JSON file (called C<links.json> by default) and turns the data
into a link site (a bit like LinkTree).

=head1 SYNOPSIS

  linksite [--file <filename>] [--help] [--version]

=head1 OPTIONS

=over 4

=item --file <filename>

Specify the path to the JSON file containing link data. Defaults to C<links.json>.

=item --help

Display usage information.

=item --version

Display the version number.

=back

=head1 EXIT STATUS

Returns zero after a successful build or an informational option. Invalid
options, including C<--file> without a filename, return status 2 without building.
Input or build failures return a non-zero status.

For more information see L<https://linksite.davecross.co.uk/>.

=cut
