93 lines
1.6 KiB
Perl
93 lines
1.6 KiB
Perl
|
#!/usr/bin/env perl
|
||
|
|
||
|
use strict;
|
||
|
use warnings;
|
||
|
#use HTML::Template;
|
||
|
|
||
|
$SIG{__WARN__} = sub { die @_; };
|
||
|
|
||
|
|
||
|
=begin comment
|
||
|
|
||
|
HOW THE ARGUMENTS ARE PROBABLY GONNA LOOK:
|
||
|
|
||
|
--new-post
|
||
|
--build=(all|modified)
|
||
|
--publish
|
||
|
[...]
|
||
|
|
||
|
TODO:
|
||
|
|
||
|
[ ] everything
|
||
|
|
||
|
=end comment
|
||
|
|
||
|
=cut
|
||
|
|
||
|
my $HELP_TEXT = << "END_HELP_TEXT";
|
||
|
Usage: staticgen.pl [options]
|
||
|
|
||
|
Put the stuff here when arguments are actually implemented.
|
||
|
END_HELP_TEXT
|
||
|
|
||
|
|
||
|
|
||
|
sub LoadConfig
|
||
|
{
|
||
|
my $filename = shift;
|
||
|
open my $cfh, "<$filename" or die "Couldn't open file!";
|
||
|
|
||
|
while (!eof($cfh))
|
||
|
{
|
||
|
my $l = <$cfh>;
|
||
|
# ^_^
|
||
|
}
|
||
|
|
||
|
close $cfh;
|
||
|
}
|
||
|
|
||
|
sub Main
|
||
|
{
|
||
|
for my $arg (@ARGV)
|
||
|
{
|
||
|
if ($arg =~ m@^(-n|-+new-post)\z@i)
|
||
|
{
|
||
|
# something
|
||
|
next;
|
||
|
}
|
||
|
|
||
|
if ($arg =~ m@^(-b|-+build)(=(?<bopt>.+))?\z@i)
|
||
|
{
|
||
|
if (defined $+{bopt})
|
||
|
{
|
||
|
if (lc $+{bopt} eq "all") { next; }
|
||
|
elsif (lc $+{bopt} eq "modified") { next; }
|
||
|
else { die "Invalid option for --build!"; }
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
next;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ($arg =~ m@^-+config=(?<conf>.+)\z@i)
|
||
|
{
|
||
|
die "Specified config file doesn't exist!"
|
||
|
unless -f $+{conf};
|
||
|
|
||
|
LoadConfig($+{conf});
|
||
|
next;
|
||
|
}
|
||
|
|
||
|
if ($arg =~ m@^(-p|-+publish)\z@i)
|
||
|
{
|
||
|
# something
|
||
|
next;
|
||
|
}
|
||
|
|
||
|
die $HELP_TEXT if ($arg =~ m@^(-h|-+help)\z@i);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
&Main();
|
||
|
exit 0;
|