App-finddo
view release on metacpan or search on metacpan
script/finddo view on Meta::CPAN
'nomedia' => sub { $_pci_args{'media'} = 0;
},
'nonewest' => sub { $_pci_args{'newest'} = 0;
},
'nooldest' => sub { $_pci_args{'oldest'} = 0;
},
'nosmallest' => sub { $_pci_args{'smallest'} = 0;
},
'novideo' => sub { $_pci_args{'video'} = 0;
},
'oldest' => sub { $_pci_args{'oldest'} = $_[1];
},
'smallest' => sub { $_pci_args{'smallest'} = $_[1];
},
'sort=s' => sub { $_pci_args{'sort'} = $_[1];
},
'version|v' => sub { },
'video' => sub { $_pci_args{'video'} = $_[1];
},
};
my $old_conf = Getopt::Long::EvenLess::Configure("pass_through");
Getopt::Long::EvenLess::GetOptions(%$go_spec1);
Getopt::Long::EvenLess::Configure($old_conf);
my $res = Getopt::Long::EvenLess::GetOptions(%$go_spec2);
_pci_err([500, "GetOptions failed"]) unless $res;
}
### check arguments
{
require Local::_pci_check_args; my $res = _pci_check_args(\%_pci_args);
_pci_err($res) if $res->[0] != 200;
$_pci_r->{args} = \%_pci_args;
}
### call function
{
my $sc_name = $_pci_r->{subcommand_name};
if ($sc_name eq "") {
$_pci_meta_result_type = "";
require App::finddo;
eval { $_pci_r->{res} = App::finddo::finddo(%_pci_args) };
if ($@) { $_pci_r->{res} = [500, "Function died: $@"] }
$_pci_r->{res} = [200, "OK (envelope added by Perinci::CmdLine::Inline)", $_pci_r->{res}];
}
}
### format & display result
{
my $fres;
my $save_res; if (exists $_pci_r->{res}[3]{"cmdline.result"}) { $save_res = $_pci_r->{res}[2]; $_pci_r->{res}[2] = $_pci_r->{res}[3]{"cmdline.result"} }
my $is_success = $_pci_r->{res}[0] =~ /\A2/ || $_pci_r->{res}[0] == 304;
my $is_stream = $_pci_r->{res}[3]{stream} // $_pci_meta_result_stream // 0;
if ($is_success && (0 || $_pci_meta_skip_format || $_pci_r->{res}[3]{"cmdline.skip_format"})) { $fres = $_pci_r->{res}[2] }
elsif ($is_success && $is_stream) {}
else { require Local::_pci_clean_json; require Perinci::Result::Format::Lite; $is_stream=0; _pci_clean_json($_pci_r->{res}); $fres = Perinci::Result::Format::Lite::format($_pci_r->{res}, ($_pci_r->{format} // $_pci_r->{res}[3]{"cmdline.default_format...
my $use_utf8 = $_pci_r->{res}[3]{"x.hint.result_binary"} ? 0 : 0;
if ($use_utf8) { binmode STDOUT, ":encoding(utf8)" }
if ($is_stream) {
my $code = $_pci_r->{res}[2]; if (ref($code) ne "CODE") { die "Result is a stream but no coderef provided" } if ($_pci_meta_result_type_is_simple) { while(defined(my $l=$code->())) { print $l; print "\n" unless $_pci_meta_result_type eq "buf"; } ...
} else {
print $fres;
}
if (defined $save_res) { $_pci_r->{res}[2] = $save_res }
}
### exit
{
my $status = $_pci_r->{res}[0];
my $exit_code = $_pci_r->{res}[3]{"cmdline.exit_code"} // ($status =~ /200|304/ ? 0 : ($status-300));
exit($exit_code);
}
=pod
=encoding UTF-8
=head1 NAME
finddo - Search for files and run command
=head1 VERSION
This document describes version 0.002 of main (from Perl distribution App-finddo), released on 2017-08-16.
=head1 SYNOPSIS
Usage:
% finddo [options] [command] ...
=head1 DESCRIPTION
I<EARLY RELEASE, MANY FEATURES ARE NOT YET IMPLEMENTED OR DEFINED.>
The I<finddo> utility is a convenient alternative for the Unix I<find> command,
for the more specific purpose of running a command with the matching files as
arguments. It provides convenience options such as C<--largest>, C<--newest>, or
C<--media>, C<--audio>, C<--video>, or C<-n>. So to play the 3 newest songs, instead
of doing:
ls --sort=t *.mp3 *.m4a *.flac *.ogg 2>/dev/null | head -n3 | xargs mpv --
and still be tripped by quoting of problematic filenames, you can just say:
finddo --newest --audio -n3 -- mpv --
=head1 OPTIONS
C<*> marks required options.
=head2 Main options
=over
=item B<--audio>
( run in 0.708 second using v1.01-cache-2.11-cpan-ba708fea25c )