]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
xt_asn: support quiet mode
authorPhilip Prindeville <philipp@redfish-solutions.com>
Mon, 10 Jul 2023 04:47:18 +0000 (06:47 +0200)
committerJan Engelhardt <jengelh@inai.de>
Mon, 10 Jul 2023 23:19:59 +0000 (01:19 +0200)
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
asn/xt_asn_build

index 4c406799480538c03efb8a5ccb9479aef3ef3060..63019ca689c56d5c9c686838fc4cc758047887e5 100755 (executable)
@@ -18,6 +18,7 @@ my $csv = Text::CSV_XS->new({
        binary => 1,
        eol => $/,
 }); # or Text::CSV
+my $quiet = 0;
 my $source_dir = ".";
 my $target_dir = ".";
 my $output_txt;
@@ -27,6 +28,7 @@ my $output_txt;
        "D=s" => \$target_dir,
        "S=s" => \$source_dir,
        "O=s" => \$output_txt,
+       "q" => \$quiet,
 );
 
 if (!-d $source_dir) {
@@ -85,7 +87,7 @@ sub collect
 
                $asns{$asn}->{pool_v4}->add($cidr);
 
-               if ($. % 4096 == 0) {
+               if (!$quiet && $. % 4096 == 0) {
                        print STDERR "\r\e[2K$. entries";
                }
 
@@ -95,7 +97,7 @@ sub collect
                }
        }
 
-       print STDERR "\r\e[2K$. entries total\n";
+       print STDERR "\r\e[2K$. entries total\n" unless ($quiet);
 
        close($fh);
 
@@ -132,7 +134,7 @@ sub collect
 
                $asns{$asn}->{pool_v6}->add($cidr);
 
-               if ($. % 4096 == 0) {
+               if (!$quiet && $. % 4096 == 0) {
                        print STDERR "\r\e[2K$. entries";
                }
 
@@ -142,7 +144,7 @@ sub collect
                }
        }
 
-       print STDERR "\r\e[2K$. entries total\n";
+       print STDERR "\r\e[2K$. entries total\n" unless ($quiet);
 
        close($fh);