#!/usr/bin/perl
use strict;
use warnings;

eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
    if 0; # not running under some shell

# FIXME -- add real $VERSION
our $VERSION = '0.01';

use SoggyOnion;
use YAML qw( LoadFile );

# hello, world!
print "started soggyonion version $VERSION on ",
    scalar localtime(time), "\n";

# process arguments -- currently, just load the configuration,
# but do a pile of error checking.
my $config;
die "usage: $0 /path/to/config.yaml\n"
    unless @ARGV == 1;
die "file $ARGV[0] doesn't exist\n"
    unless -f $ARGV[0];
die "file $ARGV[0] isn't readable\n"
    unless -r $ARGV[0];
eval {
    $config = LoadFile( $ARGV[0] );
};
die "error reading config:\n$@\n"
    if $@;

# do the thing
SoggyOnion->options( $config->{options} );
SoggyOnion->generate( $config->{layout} );
exit 0;

