forked from rho_n/hpr_generator
Add command line option for path to configuration file
Allow user to pass the path to the configuration file into the site-generator.
This commit is contained in:
parent
0f4fdc2d46
commit
14bafbc3ab
@ -9,6 +9,7 @@
|
|||||||
site-generator [OPTION]... PAGE|PAGE=<comma separated list of ids>...
|
site-generator [OPTION]... PAGE|PAGE=<comma separated list of ids>...
|
||||||
|
|
||||||
-a, --all generate all pages defined in configuration file
|
-a, --all generate all pages defined in configuration file
|
||||||
|
-c, --configure path to configuration file
|
||||||
-l, --list print list of configured pages
|
-l, --list print list of configured pages
|
||||||
-p, --preview print generated pages to standard out
|
-p, --preview print generated pages to standard out
|
||||||
-q, --quiet suppress progress information while generating pages
|
-q, --quiet suppress progress information while generating pages
|
||||||
@ -109,11 +110,13 @@ sub main {
|
|||||||
|
|
||||||
# Argument parsing
|
# Argument parsing
|
||||||
my $all;
|
my $all;
|
||||||
|
my $configuration_path;
|
||||||
my $preview;
|
my $preview;
|
||||||
my $verbose;
|
my $verbose;
|
||||||
my $quiet;
|
my $quiet;
|
||||||
GetOptions(
|
GetOptions(
|
||||||
'all' => \$all,
|
'all' => \$all,
|
||||||
|
'configuration=s' => \$configuration_path,
|
||||||
'list' => \&print_available_pages,
|
'list' => \&print_available_pages,
|
||||||
'preview' => \$preview,
|
'preview' => \$preview,
|
||||||
'verbose' => \$verbose,
|
'verbose' => \$verbose,
|
||||||
@ -126,8 +129,19 @@ sub main {
|
|||||||
$verbose = 'quiet';
|
$verbose = 'quiet';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!$configuration_path) {
|
||||||
|
$configuration_path = "site.cfg";
|
||||||
|
}
|
||||||
|
|
||||||
|
my %config;
|
||||||
|
if ( -f $configuration_path ) {
|
||||||
# Load config file
|
# Load config file
|
||||||
read_config "site.cfg" => my %config;
|
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});
|
my $tt = get_template_html($config{DBI});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user