diff options
Diffstat (limited to 'lib/Getopt/Dakkar/Option.pm')
-rw-r--r-- | lib/Getopt/Dakkar/Option.pm | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/Getopt/Dakkar/Option.pm b/lib/Getopt/Dakkar/Option.pm index 0dfd882..077f7be 100644 --- a/lib/Getopt/Dakkar/Option.pm +++ b/lib/Getopt/Dakkar/Option.pm @@ -1,5 +1,6 @@ package Getopt::Dakkar::Option; use Getopt::Dakkar::Style qw(class); +use Getopt::Dakkar::OptionValue; with 'Getopt::Dakkar::Role::Piece'; # VERSION # ABSTRACT: an option @@ -23,16 +24,26 @@ sub match($self,$arg) { sub parse($self,$args,$stash) { my $my_option = shift $args->@*; + # this will need to be extracted and made dependent on the type! + + my %arguments; # first, get arguments if needed for my $parameter ($self->parameters->@*) { my $argument = $parameter->parse($args,$stash); - # aaarg, + $arguments{$argument->name} = $argument; } # then, remove the option and put the bundle back, if needed - if ($my_option =~ /^-[^-]+/) { # we're in a bundle + if ($my_option =~ /^-[^-]{2,}/) { # we're in a bundle $my_option =~ s{^-.}{-}; unshift $args->@*, $my_option; } - return $the_option_argument; + + my $value = Getopt::Dakkar::OptionValue->new({ + name => $self->name, + # needs a way to negate a boolean! + value => %arguments ? \%arguments : 1, + }); + + return $value; } |