/[cvs]/nfo/perl/libs/Getopt/Simple.pm
ViewVC logotype

Diff of /nfo/perl/libs/Getopt/Simple.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by joko, Fri Dec 27 16:06:55 2002 UTC revision 1.4 by joko, Sat Dec 28 07:55:26 2002 UTC
# Line 2  Line 2 
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
# Line 28  use Getopt::Long; Line 31  use Getopt::Long;
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;
# Line 45  sub new { Line 53  sub new {
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 {
# Line 71  sub new { Line 80  sub new {
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;
# Line 86  sub new { Line 97  sub new {
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  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed