summaryrefslogtreecommitdiff
path: root/lib/Getopt/Dakkar/Parameter.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Getopt/Dakkar/Parameter.pm')
-rw-r--r--lib/Getopt/Dakkar/Parameter.pm31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/Getopt/Dakkar/Parameter.pm b/lib/Getopt/Dakkar/Parameter.pm
new file mode 100644
index 0000000..d544c74
--- /dev/null
+++ b/lib/Getopt/Dakkar/Parameter.pm
@@ -0,0 +1,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->@*),
+ });
+ }
+}