2 |
## $Id$ |
## $Id$ |
3 |
## ------------------------------------------------------------------------ |
## ------------------------------------------------------------------------ |
4 |
## $Log$ |
## $Log$ |
5 |
|
## Revision 1.4 2002/12/28 07:55:26 joko |
6 |
|
## - changed mechanism to read options |
7 |
|
## |
8 |
## Revision 1.3 2002/12/27 16:06:55 joko |
## Revision 1.3 2002/12/27 16:06:55 joko |
9 |
## + sub _checkRequired |
## + sub _checkRequired |
10 |
## + sub getPossibleOptionKeys |
## + sub getPossibleOptionKeys |
31 |
my $opt; |
my $opt; |
32 |
|
|
33 |
sub _cb_readOption { |
sub _cb_readOption { |
34 |
|
|
35 |
#my $self = shift; |
#my $self = shift; |
36 |
|
|
37 |
|
#print Dumper(@_); |
38 |
|
#return; |
39 |
|
|
40 |
my $opt_name = shift; |
my $opt_name = shift; |
41 |
my $opt_value = shift; |
my $opt_value = shift; |
42 |
$opt_value ||= 1; |
$opt_value ||= 1; |
53 |
#my $fields = shift; |
#my $fields = shift; |
54 |
my @fields; |
my @fields; |
55 |
foreach (@_) { |
foreach (@_) { |
56 |
|
#print ref $_, "\n"; |
57 |
if (ref $_ eq 'HASH') { |
if (ref $_ eq 'HASH') { |
58 |
$self->{__metadata} = $_; |
$self->{__metadata} = $_; |
59 |
} else { |
} else { |
80 |
} |
} |
81 |
|
|
82 |
GetOptions(@{$self->{__getopt_mapping}}); |
GetOptions(@{$self->{__getopt_mapping}}); |
83 |
|
#Getopt::Long::Configure("permute"); |
84 |
|
#GetOptions("<>" => \&_cb_readOption); |
85 |
|
|
86 |
foreach my $key (keys %{$opt}) { |
foreach my $key (keys %{$opt}) { |
87 |
push @{$self->{__available}}, $key; |
push @{$self->{__available}}, $key; |
97 |
|
|
98 |
sub _checkRequired { |
sub _checkRequired { |
99 |
my $self = shift; |
my $self = shift; |
100 |
foreach (keys %{$self->{__metadata}->{required}}) { |
foreach my $entry (@{$self->{__metadata}->{required}}) { |
101 |
if (!$self->{__result}->{$_}) { |
my $optionkey = $entry->[0]; |
102 |
$self->{__metadata}->{required}->{$_}->($self); |
my $coderef = $entry->[1]; |
103 |
|
if (!$self->{__result}->{$optionkey}) { |
104 |
|
#$self->{__metadata}->{required}->{$_}->($self); |
105 |
|
$coderef->($self); |
106 |
} |
} |
107 |
} |
} |
108 |
} |
} |