From ee393d3a6bcecbfb7afe9390a0872c2fd175f1f1 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 17 Oct 2026 06:40:05 -0400 Subject: Multiple verbosity levels (-q/--quiet added). --- TODO | 5 ++--- greypool | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/TODO b/TODO index c3a9bb2..278b05b 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,7 @@ TODO list for greypool -- add verbosity level. default to 1. --quiet makes it 0, - --verbose makes it 2. add "verbose()" that works like info(), but - only if $verbosity > 1. +- handle the case where a project has more than one maintainer... + or no maintainer. this does't happen with SlackBuilds.org. - handle ^C gracefully during wget downloads. diff --git a/greypool b/greypool index fc2ba8b..055c186 100755 --- a/greypool +++ b/greypool @@ -27,7 +27,8 @@ use POSIX 'strftime'; use feature 'unicode_strings'; $VERSION = "0.0.0"; -$verbose = $force_download = $html = 0; +$force_download = $html = 0; +$verbose = 1; # 0 = silent, 1 = info messages, 2 = debug $stamp = strftime("%Y%m%d", localtime); # defaults for HTML colors @@ -59,6 +60,11 @@ sub info { warn "$SELF: " . join(" ", @_). "\n"; } +sub debug { + return unless $verbose > 1; + warn "$SELF: " . join(" ", @_). "\n"; +} + sub read_file { undef local $/; local @ARGV = shift; @@ -68,7 +74,7 @@ sub read_file { sub parse_opts { Getopt::Long::Configure("bundling"); GetOptions( - "verbose|v" => \$verbose, + "verbose|v" => sub { $verbosity = 2; } "force|f" => \$force_download, "html|h" => \$html, "html-fragment|H" => \$html_frag, @@ -80,6 +86,7 @@ sub parse_opts { "color|colour|c" => \$color_output, "mono|no-color|no-colour|m" => sub { $color_output = 0; }, "config-dir|C=s" => \$privdir, + "quiet|q" => sub { $verbosity = 0; }, ) or fatal("error in command line options (try --help)."); $html = 1 if $html_frag; @@ -351,7 +358,7 @@ sub read_config_file { $cachedir = $privdir . "/cache/$email"; $cachestampfile = $cachedir . "/stamp"; - if($verbose) { + if($verbose > 1) { warn < 1) ? "" : "-q"; my $cmd = "wget " . @@ -520,7 +530,7 @@ sub download { "-O $filename " . "'$url'"; - info $cmd; + debug $cmd; my $status = system($cmd); if($status) { fatal "wget failed, exit status " . ($status >> 8); @@ -541,6 +551,10 @@ sub generate_report { $lastpkg = parse_file($filecount++); } + if(!$download_count) { + info "using cached data"; + } + print_report_header(); my $count = 0; if(!keys %report) { @@ -758,11 +772,16 @@ Comma-separated value output. The first line is a "header" with the field names; the rest of the output is one line per package. This would fail if someone put a comma in a version number... I<*shrug*> +=item B<-q>, B<--quiet> + +Don't print any messages to standard error, except errors and +warning. + =item B<-v>, B<--verbose> -Print informational messages about what B is doing, +Print extra informational messages about what B is doing, including the B(1) progress bar during downloads. Messages go -to standard error outpu. +to standard error output. =item B<-V>, B<--version> -- cgit v1.2.3