r5985 - trunk/eda/boom

werner at docs.openmoko.org werner at docs.openmoko.org
Sat Oct 16 13:14:38 CEST 2010


Author: werner
Date: 2010-10-16 13:14:37 +0200 (Sat, 16 Oct 2010)
New Revision: 5985

Modified:
   trunk/eda/boom/prettyord
Log:
boom/prettyord: added option -t to display totals



Modified: trunk/eda/boom/prettyord
===================================================================
--- trunk/eda/boom/prettyord	2010-10-16 01:03:56 UTC (rev 5984)
+++ trunk/eda/boom/prettyord	2010-10-16 11:14:37 UTC (rev 5985)
@@ -6,16 +6,20 @@
 
 sub usage
 {
-    print STDERR "usage: $0 [-s/from/to/ ...] ...\n";
+    print STDERR "usage: $0 [-s/from/to/ ...] [-t] ...\n";
     exit(1);
 }
 
-
-while ($ARGV[0] =~ /^-s/) {
-    &usage unless &dsc_xlat_arg($');
+while ($ARGV[0] =~ /^-./) {
+    if ($ARGV[0] =~ /^-s/) {
+	&usage unless &dsc_xlat_arg($');
+    } elsif ($ARGV[0] eq "-t") {
+	$total = 1;
+    } else {
+	&usage;
+    }
     shift @ARGV;
 }
-&usage if $ARGV[0] =~ /^-./;
 
 &parse;
 
@@ -36,6 +40,7 @@
     push(@{ $out[3] }, defined $dsc ? $dsc : "???");
     push(@{ $out[4] }, $order{$_}[1]);
     push(@{ $out[5] }, sprintf("%.2f", $order{$_}[2]));
+    $price{$order{$_}[1]} += $order{$_}[2];
 }
 
 for (@out) {
@@ -68,3 +73,11 @@
     $l =~ s/\s*$//;
     print "$l\n";
 }
+
+if ($total) {
+    print "$n item".($n == 1 ? "" : "s");
+    for (sort keys %price) {
+	print ", $_ $price{$_}";
+    }
+    print "\n";
+}




More information about the commitlog mailing list