about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-06-16 01:45:08 +0530
committerAndinus <andinus@nand.sh>2020-06-16 01:45:08 +0530
commit56fb679669d6320c4dd0a43352a10fd9a150a315 (patch)
treefd3bcf273e8ae9de5151586d3bfd7792872124d1
parentf1477cdab1454bba261bed22d989857d04a4ba9b (diff)
downloadara-56fb679669d6320c4dd0a43352a10fd9a150a315.tar.gz
Add showdelta option
-rwxr-xr-xara.pl28
1 files changed, 15 insertions, 13 deletions
diff --git a/ara.pl b/ara.pl
index 569befa..c6c898b 100755
--- a/ara.pl
+++ b/ara.pl
@@ -31,19 +31,19 @@ foreach my $path (@INC) {
 }
 
 my ( $use_local_file, $get_latest, $state_notes, $rows_to_print, $no_delta,
-     $no_total, @to_hide, %hide, @to_show, %show, $no_words );
+     $no_total, @to_hide, %hide, @to_show, %show, $no_words, $show_delta );
 
 sub HelpMessage {
     print LOCALCOLOR GREEN "Options:
-    --local   Use local data
-    --latest  Fetch latest data
-    --notes   Print State Notes
-    --rows=i  Number of rows to print (i is Integer)
-    --nodelta Don't print changes in values
-    --nototal Don't print 'Total' row
-    --nowords Don't format numbers with words
-    --hide    Hide states, columns from table (space seperated)
-    --show    Show only these states (space seperated)";
+    --local     Use local data
+    --latest    Fetch latest data
+    --notes     Print State Notes
+    --rows=i    Number of rows to print (i is Integer)
+    --showdelta Print delta values for all rows
+    --nodelta   Don't print changes in values
+    --nowords   Don't format numbers with words
+    --hide      Hide states, columns from table (space seperated)
+    --show      Show only these states (space seperated)";
     print LOCALCOLOR CYAN "
     --help    Print this help message
 ";
@@ -55,6 +55,7 @@ GetOptions(
     "latest" => \$get_latest,
     "notes" => \$state_notes,
     "rows=i" => \$rows_to_print,
+    "showdelta" => \$show_delta,
     "nodelta" => \$no_delta,
     "nototal" => \$no_total,
     "nowords" => \$no_words,
@@ -271,9 +272,10 @@ foreach my $i ( 0 ... scalar @$statewise - 1 ) {
         my $recovered = $fmt->format_number("$statewise->[$i]{recovered}");
         my $deaths = $fmt->format_number("$statewise->[$i]{deaths}");
 
-        # Add delta only if it was updated Today.
-        if ( $update_info eq "Today"
-                 and not $no_delta ) {
+        # Add delta only if it was updated Today or if user has asked.
+        if ( $show_delta
+                 or ( $update_info eq "Today"
+                      and not $no_delta ) ) {
             # Only delta number will get highlighted.
             $_ .= " " for ($confirmed, $recovered, $deaths);