summaryrefslogtreecommitdiff
path: root/lib/Getopt/Dakkar/Parameter.pm
blob: d544c746dfb228f7b0e7d6040a0e66cedf04c2cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package Getopt::Dakkar::Parameter; 
use Getopt::Dakkar::Style qw(class);
use Getopt::Dakkar::Argument;
with 'Getopt::Dakkar::Role::Piece';
# VERSION 
# ABSTRACT: a (positional) parameter 
 
# this will need to be generalised and depend on the type 
has is_slurpy => ( is => 'ro'isa => Bool, default => 0 );
 
sub match($self,$arg) {
    # this may need to throw if the type is wrong? 
    return 1;
}
 
sub parse($self,$args,$stash) {
    if ($self->is_slurpy) {
        my $value = [ $args->@* ];
        $args->@* = ();
        return Getopt::Dakkar::Argument->new({
            name => $self->name,
            value => $value,
        });
    }
    else {
        return Getopt::Dakkar::Argument->new({
            name => $self->name,
            value => (shift $args->@*),
        });
    }
}