From a95ed98278a52764449fa89c3ce30b7bec1d3df1 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Tue, 30 May 2023 05:00:04 -0400 Subject: sbolint: add progress bar. --- sbolint | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/sbolint b/sbolint index da5318e..675685f 100755 --- a/sbolint +++ b/sbolint @@ -318,6 +318,7 @@ $g_warncount = 0; $g_errcount = 0; $warncount = 0; $errcount = 0; +$progress_bar = 0; $tempdir = 0; @@ -374,6 +375,10 @@ if($stdin) { } if($recursive_git) { + if(-t STDOUT) { + die "$SELF: you don't want to use -a without redirecting. Example:\n $SELF -a > lint.log\n"; + } + @ARGV=(); my $pwd; @@ -392,7 +397,7 @@ if($recursive_git) { } warn "$SELF: linting " . scalar(@ARGV) . " builds from git repo at $pwd\n" unless $quiet; - $quiet = 1; + $quiet = $progress_bar = 1; } push @ARGV, "." unless @ARGV; @@ -401,6 +406,7 @@ push @ARGV, "." unless @ARGV; # the junkfile check is skipped. $in_git_repo = system("git rev-parse >/dev/null 2>/dev/null") == 0; +$argv_count = 0; for(@ARGV) { run_checks($_); $g_errcount += $errcount; @@ -413,6 +419,20 @@ for(@ARGV) { print "$SELF: $buildname: " . $red . "errors $errcount" . $color_off . ", " . $yellow . "warnings $warncount" . $color_off . "\n"; } } + + if($progress_bar) { + $argv_count++; + my $pct = ($argv_count / @ARGV) * 100; + printf STDERR " %d/%d, %2.1f%%\r", $argv_count, scalar @ARGV, $pct; + } +} + +if($progress_bar) { + chomp (my $now = `date +%s`); + my $elapsed = $now - $^T; + my $min = int($elapsed / 60); + my $sec = $elapsed % 60; + printf STDERR "\nElapsed time %d:%02d\n", $min, $sec; } # print total errs/warns only if >1 build checked -- cgit v1.2.3