Update of /cvsroot/fink/scripts/pdb
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26356

Modified Files:
        dump 
Log Message:
Allow use of getopt flags instead of positional parameters


Index: dump
===================================================================
RCS file: /cvsroot/fink/scripts/pdb/dump,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- dump        3 Jan 2006 19:37:50 -0000       1.27
+++ dump        4 Apr 2006 21:52:10 -0000       1.28
@@ -31,14 +31,33 @@
 use Fink::Package;
 use Fink::Command qw(rm_f);
 
-### read config
-
-my $config = &read_config("fink.conf");
+use Getopt::Long;
 
 ### get parameters
-my $distribution = shift || "10.3";
-my $tree = shift || "stable";
-my $release = shift || "current-$distribution-$tree";
+my ($distribution, $tree, $release, $architecture);
+
+# process command-line
+if (@ARGV && $ARGV[0] =~ /^-/) {
+    # have a getopt flag, so use getopt syntax
+    GetOptions(
+       'distribution=s' => \$distribution,
+       'tree=s'         => \$tree,
+       'release=s'      => \$release
+       )
+       or die "$0: Bad syntax\n";
+} else {
+    # no getopt flag, so use old positional-parameter syntax
+    ($distribution, $tree, $release) = @_;
+    die "$0: Bad syntax\n" if @ARGV > 3;
+}
+
+# set defaults for missing values
+defined $distribution or $distribution = "10.3";
+defined $tree         or $tree         = "stable";
+defined $release      or $release      = "current-$distribution-$tree";
+
+### read config
+my $config = &read_config("fink.conf");
 
 ### read package info
 



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Fink-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to