diff options
author | Matias Linares <matias@deprecated.org> | 2024-06-19 18:09:43 -0300 |
---|---|---|
committer | Matias Linares <matias@deprecated.org> | 2024-06-19 18:09:43 -0300 |
commit | 5d0a0b65e7eb219eff2eee198b8b7e266b36c016 (patch) | |
tree | 7914803fa1893cdf6249621183e264f51a19d489 /ssg | |
parent | 118e0b0eb6db115e12cd737d8286c3545ea95c3d (diff) | |
download | ssg-5d0a0b65e7eb219eff2eee198b8b7e266b36c016.tar.gz |
Diffstat (limited to 'ssg')
-rwxr-xr-x | ssg | 60 |
1 files changed, 30 insertions, 30 deletions
@@ -2,16 +2,17 @@ use v5.38; use strict; use warnings; +use experimental 'signatures'; use local::lib; use File::Path qw(make_path remove_tree); use Path::Class; -use Getopt::Std; +use Getopt::Long; # Root in directory. -my $indir; -my $outdir; +our $indir; +our $outdir; my $VERSION = "v0.1"; my @exlude_files = ( @@ -203,33 +204,32 @@ sub run_on { } } -my %opts = ( - 'v' => 0, - 'h' => 0, - 'o' => "site.static/", - 's' => 1, -); -getopts('svho:', \%opts); -$indir = shift @ARGV; - -if($opts{h}) { - help; - exit 0; -} elsif($opts{v}) { - version; - exit 0; -} +sub main { + my $help; + my $version; + my $output_path = 'site.static/'; + my $sidebar = 1; + GetOptions(help => \$help, + version => \$version, + "output-path=s", \$output_path, + "sidebar" => \$sidebar) or die "Error in command line arguments\n"; + $indir = shift @ARGV; + + if($help) { + help; + exit 0; + } elsif ($version) { + version(); + exit 0; + } -if(-d $opts{o}) { - print STDERR "removing $opts{o}\n"; - remove_tree($opts{o}); -} + if (-d $output_path) { + print STDERR "Removing $output_path\n"; + remove_tree($output_path); + } -if($opts{s}) { - $with_sidebar = $opts{s}; + $outdir = $output_path; + mkdir $output_path; + run_on $indir; } - -mkdir $opts{o}; -$outdir = $opts{o}; - -run_on $indir; +main; |