Archived
4
2

Add option to site-generator to list configured pages

This commit is contained in:
Roan Horning 2022-08-08 21:30:22 -04:00
parent bccfa695a3
commit 818fc25ff9
Signed by: rho_n
GPG Key ID: 234AEF20B72D5769

View File

@ -8,6 +8,7 @@
site-generator [OPTION]... PAGE|PAGE=<comma separated list of ids>...
-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
@ -95,6 +96,7 @@ sub main {
my $verbose;
my $quiet;
GetOptions(
'list' => \&print_available_pages,
'preview' => \$preview,
'verbose' => \$verbose,
'quiet' => \$quiet,
@ -275,3 +277,20 @@ sub get_filename {
}
return $filename;
}
sub print_available_pages {
# Load config file
read_config "site.cfg" => my %config;
my @page_args = sort (keys %config);
# Remove non page sections of the configuration file
# from the generated list of pages.
@page_args= grep { $_ ne 'DBI' } @page_args;
@page_args= grep { $_ ne 'root_template' } @page_args;
foreach my $page_arg (@page_args) {
print "$page_arg\n";
}
exit;
}