App-GitFind

 view release on metacpan or  search on metacpan

lib/App/GitFind/Actions.pm  view on Meta::CPAN

    map( { _a $_, qr/^;$/ } qw(ok okdir) ),
);

# }}}1
# === Argument-validation functions === {{{1
# Special validators for ok, okdir, exec, and execdir.
# Validators return undefined if validation passes, and an error message
# otherwise.  Validators take the command and the located parameters
# in @_.

sub _validate_exec {
    return "need at least a command name" unless $#_>1;
    if($_[$#_] eq '+') {
        return "need a {}" unless grep { $_ eq '{}' } @_;
        return "{} can't be the first argument to $_[0]" if $_[1] eq '{}';
    }
    return undef;
}

sub _validate_ok {
    return "need at least a command name" unless $#_>1;
    return undef;
}

# }}}1
# === Accessors for argument information === {{{1

=head2 ARGTEST

Returns a regex that will match any arg, with C<-> or C<--> prefix.  The arg

lib/App/GitFind/Actions.pm  view on Meta::CPAN

        $inflated = true;
        _inflate($package);

    }
} #import()

# Inflate %ARGS.  Arg is the package providing the actions; no return.
sub _inflate {
    my $package = $_[0];
    # Hook the validators into %ARGS
    $ARGS{exec}->{validator} = \&_validate_exec;
    $ARGS{execdir}->{validator} = $ARGS{exec}->{validator};
    $ARGS{ok}->{validator} = \&_validate_ok;
    $ARGS{okdir}->{validator} = $ARGS{ok}->{validator};

    # Hook the actions into %ARGS
    while (my ($key, $hrValue) = each %ARGS)  {
        my $fn = $package->can("do_$key");
        next unless $fn;
        $hrValue->{code} = $fn;
    }
} #_inflate()



( run in 0.608 second using v1.01-cache-2.11-cpan-4d50c553e7e )