diff options
| author | B. Watson <urchlay@slackware.uk> | 2026-10-17 06:40:05 -0400 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2026-10-17 06:40:05 -0400 |
| commit | ee393d3a6bcecbfb7afe9390a0872c2fd175f1f1 (patch) | |
| tree | 007b59ebf9e132ed4413e3a3cbeb183e1fe50e41 | |
| parent | cc8b067ef1db3b2461a44403e4c79c6a2014e7c6 (diff) | |
| download | greypool-ee393d3a6bcecbfb7afe9390a0872c2fd175f1f1.tar.gz | |
Multiple verbosity levels (-q/--quiet added).
| -rw-r--r-- | TODO | 5 | ||||
| -rwxr-xr-x | greypool | 39 |
2 files changed, 31 insertions, 13 deletions
@@ -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. @@ -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 <<EOF; config summary: cachedir: $cachedir @@ -369,7 +376,7 @@ EOF sub decode_file { $_ = shift; - info("decoding JSON file $_"); + debug("decoding JSON file $_"); eval { $j = decode_json(read_file($_)); @@ -433,7 +440,7 @@ sub parse_file { } } - info "$count entries in file, last package $lastpkg\n"; + debug "$count entries in file, last package $lastpkg\n"; return $lastpkg eq $firstpkg ? undef : $lastpkg; } @@ -504,14 +511,17 @@ sub download { my $filename = $cachedir . "/" . $num . ".json"; if(!$force_download && (-e $filename)) { - info "$filename found in cache, not downloading"; + debug "$filename found in cache, not downloading"; return; } + info "downloading JSON file #$num"; + $download_count++; + if($no_download && (! -e $filename)) { fatal "-n / --cached option given, but no cached data in $cachedir"; } - my $qopt = $verbose ? "" : "-q"; + my $qopt = ($verbose > 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<greypool> is doing, +Print extra informational messages about what B<greypool> is doing, including the B<wget>(1) progress bar during downloads. Messages go -to standard error outpu. +to standard error output. =item B<-V>, B<--version> |
