diff --git a/site-generator b/site-generator index 61b515b..42331f0 100755 --- a/site-generator +++ b/site-generator @@ -8,12 +8,13 @@ site-generator [OPTION]... PAGE|PAGE=... - -a, --all generate all pages defined in configuration file - -l, --list print list of configured pages - -p, --preview print generated pages to standard out - -q, --quiet suppress progress information while generating pages - -v, --verbose print extended progress information while generating pages - --help print this help message + -a, --all generate all pages defined in configuration file + -c, --configure path to configuration file + -l, --list print list of configured pages + -p, --preview print generated pages to standard out + -q, --quiet suppress progress information while generating pages + -v, --verbose print extended progress information while generating pages + --help print this help message Where I is a file name of a web page or the special I (to generate all pages). @@ -109,15 +110,17 @@ sub main { # Argument parsing my $all; + my $configuration_path; my $preview; my $verbose; my $quiet; GetOptions( - 'all' => \$all, - 'list' => \&print_available_pages, - 'preview' => \$preview, - 'verbose' => \$verbose, - 'quiet' => \$quiet, + 'all' => \$all, + 'configuration=s' => \$configuration_path, + 'list' => \&print_available_pages, + 'preview' => \$preview, + 'verbose' => \$verbose, + 'quiet' => \$quiet, ) or pod2usage(1); pod2usage(1) unless @ARGV || $all; my (@page_args) = @ARGV; @@ -126,8 +129,19 @@ sub main { $verbose = 'quiet'; }; - # Load config file - read_config "site.cfg" => my %config; + if (!$configuration_path) { + $configuration_path = "site.cfg"; + } + + my %config; + if ( -f $configuration_path ) { + # Load config file + read_config $configuration_path => %config; + } + else { + print STDOUT "Could not read configuration file: $configuration_path\n"; + exit 1; + } my $tt = get_template_html($config{DBI});