App-GitFind
view release on metacpan or search on metacpan
lib/App/GitFind/Actions.pm view on Meta::CPAN
sub do_ls {
state $loaded = (require App::GitFind::FileStatLs, true);
print App::GitFind::FileStatLs::ls_stat($_[1]->path);
true
}
# TODO optimization? Pull the stat() results from $_[1] rather than
# re-statting. May not be an issue.
sub do_print {
say $_[0]->dot_relative_path($_[1]);
true
}
sub do_print0 { print $_[0]->dot_relative_path($_[1]), "\0"; true }
# prune
# quit
# This appears to be a GNU extension. It should:
# - Finish any child processes
lib/App/GitFind/Base.pm view on Meta::CPAN
chomp $log[$#log] if $log[$#log];
# TODO add an option to number the lines of the output
my $msg = join(' ', @log);
$msg =~ s/^/# /gm;
if($VERBOSE >= 4) {
my ($package, $filename, $line) = caller;
$msg .= " (at $filename:$line)";
}
say STDERR $msg;
} #vlog()
=head2 vwarn
As L</vlog>, but warns regardless of L</$VERBOSE>. Does respect L</$QUIET>.
=cut
sub vwarn (&) {
return if $QUIET;
lib/App/GitFind/cmdline.pm view on Meta::CPAN
return false unless defined $arg and length($arg)>0;
return scalar($arg =~ m{$_rev_regex});
} #_is_valid_rev()
# Get an expression element from the array passed in $_[0].
my $ARGTEST_cached = App::GitFind::Actions::ARGTEST();
sub _consume_expression_element {
my $lrArgv = shift;
my @retval;
#say STDERR "# Trying >>$lrArgv->[0]<<";
# TODO find(1) positional options, global options?
# Regular options
if($lrArgv->[0] =~ $ARGTEST_cached) {
#say STDERR "# - matched";
my $arg = $1;
my %opts = %{App::GitFind::Actions::argdetails($arg)};
# Save any non-parser information from the argdetails to be
# returned as part of the semantic value.
my %extras = %opts;
delete @extras{qw(token nparam)};
# No-argument tests or actions
unless($opts{nparam}>0) {
#say STDERR "# - No parameters";
shift @$lrArgv;
return ($opts{token} => { name => $arg, %extras })
}
# Consume additional arguments up to a regexp
if(ref $opts{nparam} eq 'Regexp') {
#say STDERR "# - parameters until $opts{nparam}";
die "Need argument(s) for --$arg" if @$lrArgv == 1;
my $lastarg;
#say STDERR "Args: ", join ' : ', @$lrArgv;
for(1..$#$lrArgv) {
$lastarg=$_, last if $lrArgv->[$_] =~ $opts{nparam};
}
die "--$arg needs an argument terminator matching $opts{nparam}"
unless defined $lastarg;
# Set up to fall through to the numeric-params case
$opts{nparam} = $lastarg;
}
# Consume additional positional arguments
#say STDERR "# - $opts{nparam} parameters";
die "Not enough parameters after --$arg (need $opts{nparam})"
unless @$lrArgv >= ($opts{nparam}+1); # +1 for $arg itself
# Custom argument validation
if($opts{validator}) {
my $errmsg = $opts{validator}->(@{$lrArgv}[0..$opts{nparam}]);
die "--$arg argument error: $errmsg" if defined($errmsg);
}
@retval = ($opts{token} => {
support/cmdline.yp view on Meta::CPAN
return false unless defined $arg and length($arg)>0;
return scalar($arg =~ m{$_rev_regex});
} #_is_valid_rev()
# Get an expression element from the array passed in $_[0].
my $ARGTEST_cached = App::GitFind::Actions::ARGTEST();
sub _consume_expression_element {
my $lrArgv = shift;
my @retval;
#say STDERR "# Trying >>$lrArgv->[0]<<";
# TODO find(1) positional options, global options?
# Regular options
if($lrArgv->[0] =~ $ARGTEST_cached) {
#say STDERR "# - matched";
my $arg = $1;
my %opts = %{App::GitFind::Actions::argdetails($arg)};
# Save any non-parser information from the argdetails to be
# returned as part of the semantic value.
my %extras = %opts;
delete @extras{qw(token nparam)};
# No-argument tests or actions
unless($opts{nparam}>0) {
#say STDERR "# - No parameters";
shift @$lrArgv;
return ($opts{token} => { name => $arg, %extras })
}
# Consume additional arguments up to a regexp
if(ref $opts{nparam} eq 'Regexp') {
#say STDERR "# - parameters until $opts{nparam}";
die "Need argument(s) for --$arg" if @$lrArgv == 1;
my $lastarg;
#say STDERR "Args: ", join ' : ', @$lrArgv;
for(1..$#$lrArgv) {
$lastarg=$_, last if $lrArgv->[$_] =~ $opts{nparam};
}
die "--$arg needs an argument terminator matching $opts{nparam}"
unless defined $lastarg;
# Set up to fall through to the numeric-params case
$opts{nparam} = $lastarg;
}
# Consume additional positional arguments
#say STDERR "# - $opts{nparam} parameters";
die "Not enough parameters after --$arg (need $opts{nparam})"
unless @$lrArgv >= ($opts{nparam}+1); # +1 for $arg itself
# Custom argument validation
if($opts{validator}) {
my $errmsg = $opts{validator}->(@{$lrArgv}[0..$opts{nparam}]);
die "--$arg argument error: $errmsg" if defined($errmsg);
}
@retval = ($opts{token} => {
( run in 2.235 seconds using v1.01-cache-2.11-cpan-d7a12ab2c7f )