Add quiet option to site-generator

Suppress progress information while generating pages.
This commit is contained in:
Roan Horning 2022-08-07 21:49:10 -04:00
parent 4725547d39
commit a194a28b71
Signed by untrusted user: rho_n
GPG Key ID: 234AEF20B72D5769

View File

@ -9,7 +9,8 @@
site-generator [OPTION]... PAGE|PAGE=<comma separated list of ids>...
-p, --preview print generated pages to standard out
-v, --verbose use verbose mode
-q, --quiet suppress progress information while generating pages
-v, --verbose print extended progress information while generating pages
--help print this help message
Where I<PAGE> is a file name of a web page
@ -92,13 +93,19 @@ sub main {
# Argument parsing
my $preview;
my $verbose;
my $quiet;
GetOptions(
'preview' => \$preview,
'verbose' => \$verbose,
'verbose' => \$verbose,
'quiet' => \$quiet,
) or pod2usage(1);
pod2usage(1) unless @ARGV;
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
@ -186,7 +193,9 @@ sub generate_page {
sub verbose {
my ($verbose, $message) = @_;
if ($verbose) {
print STDOUT "$message\n";
if ($verbose ne 'quiet') {
print STDOUT "$message\n";
}
}
else {
STDOUT->autoflush(1);