diff --git a/README.md b/README.md index 1b91dfe..1bdf28f 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/site-generator b/site-generator index 562b6a6..1ad2734 100755 --- a/site-generator +++ b/site-generator @@ -8,6 +8,7 @@ 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 @@ -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