Add command line option all
Use --all or -a when calling site-generator instead of special page ALL to generate all the configured pages for a website.
This commit is contained in:
parent
b36293e52f
commit
694c100bcf
@ -26,7 +26,7 @@ Generate two specific pages:
|
||||
`site-generator index about`
|
||||
|
||||
Generate the whole site:
|
||||
`site-generator ALL`
|
||||
`site-generator --all`
|
||||
|
||||
Generate pages based on the same template:
|
||||
`site-generator correspondent=1,3,5..10`
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
site-generator [OPTION]... PAGE|PAGE=<comma separated list of ids>...
|
||||
|
||||
-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
|
||||
@ -23,7 +24,7 @@
|
||||
site-generator index about
|
||||
|
||||
Generate the whole site:
|
||||
site-generator ALL
|
||||
site-generator --all
|
||||
|
||||
Generate pages based on the same template:
|
||||
site-generator correspondent=1,3,5..10
|
||||
@ -92,33 +93,32 @@ exit main();
|
||||
sub main {
|
||||
|
||||
# Argument parsing
|
||||
my $all;
|
||||
my $preview;
|
||||
my $verbose;
|
||||
my $quiet;
|
||||
GetOptions(
|
||||
'all' => \$all,
|
||||
'list' => \&print_available_pages,
|
||||
'preview' => \$preview,
|
||||
'verbose' => \$verbose,
|
||||
'quiet' => \$quiet,
|
||||
) or pod2usage(1);
|
||||
pod2usage(1) unless @ARGV;
|
||||
pod2usage(1) unless @ARGV || $all;
|
||||
my (@page_args) = @ARGV;
|
||||
|
||||
if ($quiet) {
|
||||
$verbose = 'quiet';
|
||||
};
|
||||
|
||||
# Set flag indicating whether or not to generate all pages.
|
||||
# The flag is set to true if the special argument ALL is
|
||||
# passed into the generator
|
||||
my $ALL = grep { $_ eq 'ALL' } @page_args;
|
||||
|
||||
# Load config file
|
||||
read_config "site.cfg" => my %config;
|
||||
|
||||
my $tt = get_template_html($config{DBI});
|
||||
|
||||
if ($ALL) {
|
||||
# If command line option all is set, parse configuration file
|
||||
# for all pages
|
||||
if ($all) {
|
||||
@page_args = keys %config;
|
||||
|
||||
# Remove non page sections of the configuration file
|
||||
|
Reference in New Issue
Block a user