change rules for cluster accessible dirs.
[cxgn-corelibs.git] / lib / CXGN / Garbage / cmdline_args.pm
blobd0fcdeb6bc75ca2097724483815ab517178797f6
1 package CXGN::Garbage::cmdline_args;
2 use strict;
4 sub get_options {
5 my ($validopt_ref, $argv_ref) = @_;
6 my ($option, $error);
8 if (! @{$argv_ref}) {
9 print "No command line options\n";
10 return 0;
13 while(@{$argv_ref}>0) {
14 $option = shift @{$argv_ref};
16 if (! defined($validopt_ref->{$option})) {
17 print STDERR "Unknown option $option\n";
18 $error = 1;
19 next;
22 if ($validopt_ref->{$option}->[1]) {
23 # Option which requires argument, shift in the next argument from
24 # the command line
25 ${$validopt_ref->{$option}->[0]} = shift @{$argv_ref};
26 } else {
27 # Boolean flag: invert default value
28 if (${$validopt_ref->{$option}->[0]}) {
29 ${$validopt_ref->{$option}->[0]} = 0;
30 } else {
31 ${$validopt_ref->{$option}->[0]} = 1;
36 return $error;
38 return 1;