From 7fce4340deb0b6337bbd7ef6071ee42529db222d Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 13 Jul 2018 13:09:26 +0100 Subject: vaguely parse commands --- lib/Getopt/Dakkar/Role/Piece.pm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lib/Getopt/Dakkar/Role/Piece.pm (limited to 'lib/Getopt/Dakkar/Role/Piece.pm') diff --git a/lib/Getopt/Dakkar/Role/Piece.pm b/lib/Getopt/Dakkar/Role/Piece.pm new file mode 100644 index 0000000..d981095 --- /dev/null +++ b/lib/Getopt/Dakkar/Role/Piece.pm @@ -0,0 +1,22 @@ +package Getopt::Dakkar::Role::Piece; +use Getopt::Dakkar::Style qw(role); +# VERSION +# ABSTRACT: a piece + +has class => ( is => 'ro', isa => ClassName, default => 'Getopt::Dakkar::Stash' ); +has object => ( is => 'ro', isa => Object ); +has op => ( is => 'ro', isa => Str|CodeRef ); + +sub make_stash($self,$argpack) { + if (my $o = $self->object) { return $o } + + my $class = use_module($self->class); + if (my $from_argpack = $class->can('new_from_argpack')) { + return $class->$from_argpack($argpack); + } + else { + return $class->new(); + } +} + +requires 'parse'; -- cgit v1.2.3