Skip to content

Instantly share code, notes, and snippets.

@berekuk
Created June 8, 2011 18:24
Show Gist options
  • Select an option

  • Save berekuk/1014999 to your computer and use it in GitHub Desktop.

Select an option

Save berekuk/1014999 to your computer and use it in GitHub Desktop.
mx-getopt-delegation
#!/usr/bin/perl
package Context;
use Moose;
has [qw( a b c )] => (
is => 'ro',
isa => 'Bool',
default => 1,
);
package Script;
use Moose;
with 'MooseX::Getopt';
has 'context' => (
is => 'ro',
isa => 'Context',
handles => [qw( a b c )],
);
sub main {
my $self = shift;
my $context = $self->context;
if ($context->a) {
# do a
}
if ($context->b) {
# do b
}
if ($context->c) {
# do c
}
}
__PACKAGE__->new_with_options->main;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment