App-shcompgen
view release on metacpan or search on metacpan
lib/App/shcompgen.pm view on Meta::CPAN
my $envres = envresmulti();
PROG:
for my $prog0 (@{ $args{prog} }) {
my ($prog, $progpath);
log_debug("Processing program %s ...", $prog0);
if ($prog0 =~ m!/!) {
($prog = $prog0) =~ s!.+/!!;
$progpath = $prog0;
unless (-f $progpath) {
log_error("No such file %s, skipped", $progpath);
$envres->add_result(404, "No such file", {item_id=>$prog0});
next PROG;
}
} else {
require File::Which;
$prog = $prog0;
$progpath = File::Which::which($prog0);
unless ($progpath) {
log_error("'%s' not found in PATH, skipped", $prog0);
$envres->add_result(404, "Not in PATH", {item_id=>$prog0});
next PROG;
}
}
my $which = $which0;
if ($which eq 'generate') {
my $detres = _detect_prog(prog=>$prog, progpath=>$progpath, shell=>$args{shell});
if ($detres->[0] != 200) {
log_error("Can't detect '%s': %s", $prog, $detres->[1]);
$envres->add_result($detres->[0], $detres->[1],
lib/App/shcompgen.pm view on Meta::CPAN
sub detect_prog {
require File::Which;
my %args = @_;
_set_args_defaults(\%args);
my $progname = $args{prog};
my $progpath = File::Which::which($progname);
return [404, "No such program '$progname'"] unless $progpath;
$progname =~ s!.+/!!;
_detect_prog(
prog => $progname,
progpath => $progpath,
shell => $args{shell},
);
}
$SPEC{init} = {
( run in 2.134 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )