App-AcmeCpanauthors
view release on metacpan or search on metacpan
script/_acme-cpanauthors view on Meta::CPAN
chomp($header_line);
if ($header_line eq 'Data::Section::Seekable v1') {
$header_found++;
last;
}
}
die "Can't find header 'Data::Section::Seekable v1'"
unless $header_found;
my %toc;
my $i = 0;
while (1) {
$i++;
my $toc_line = <$fh>;
defined($toc_line)
or die "Unexpected end of data section while reading TOC line #$i";
chomp($toc_line);
$toc_line =~ /\S/ or last;
$toc_line =~ /^([^,]+),(\d+),(\d+)(?:,(.*))?$/
or die "Invalid TOC line #$i in data section: $toc_line";
$toc{$1} = [$2, $3, $4];
}
my $pos = tell $fh;
$toc{$_}[0] += $pos for keys %toc;
# calculate the line number of data section
my $data_pos = tell(DATA);
seek DATA, 0, 0;
my $pos = 0;
while (1) {
my $line = <DATA>;
$pos += length($line);
$data_linepos++;
last if $pos >= $data_pos;
}
seek DATA, $data_pos, 0;
\%toc;
};
if ($toc->{$_[1]}) {
warn "[datapacker] $_[1] FOUND in packed modules\n" if $debug;
seek DATA, $toc->{$_[1]}[0], 0;
read DATA, my($content), $toc->{$_[1]}[1];
my ($order, $lineoffset) = split(';', $toc->{$_[1]}[2]);
$content =~ s/^#//gm;
$content = "# line ".($data_linepos + $order+1 + $lineoffset)." \"".__FILE__."\"\n" . $content;
open my $fh, '<', \$content
or die "DataPacker error loading $_[1]: $!";
return $fh;
} else {
warn "[datapacker] $_[1] NOT found in packed modules\n" if $debug;
}
return;
}; # handler
unshift @INC, bless(sub {"dummy"}, "main::_DataPacker");
}
# END DATAPACK CODE
# Note: This completer script is generated by App::GenPericmdCompleterScript version 0.125
# on Sat Jun 17 09:02:58 2023. You probably should not manually edit this file.
# NO_PERINCI_CMDLINE_SCRIPT
# PERINCI_CMDLINE_COMPLETER_SCRIPT: {load_module=>["App::AcmeCpanauthors"],program_name=>"acme-cpanauthors",read_config=>0,read_env=>0,skip_format=>undef,subcommands=>undef,url=>"/App/AcmeCpanauthors/acme_cpanauthors"}
# FRAGMENT id=shcompgen-hint completer=1 for=acme-cpanauthors
# PODNAME: _acme-cpanauthors
# ABSTRACT: Completer script for acme-cpanauthors
use 5.010;
use strict;
use warnings;
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2023-06-17'; # DATE
our $DIST = 'App-AcmeCpanauthors'; # DIST
our $VERSION = '0.004'; # VERSION
die "Please run this script under shell completion\n" unless $ENV{COMP_LINE} || $ENV{COMMAND_LINE};
# require extra modules
use App::AcmeCpanauthors ();
my $args = {load_module=>["App::AcmeCpanauthors"],program_name=>"acme-cpanauthors",read_config=>0,read_env=>0,skip_format=>undef,subcommands=>undef,url=>"/App/AcmeCpanauthors/acme_cpanauthors"};
my $meta = {_orig_args_as=>undef,_orig_result_naked=>undef,args=>{action=>{cmdline_aliases=>{L=>{code=>sub{package App::AcmeCpanauthors;use warnings;use strict;no feature;use feature ':5.10';$_[0]{'action'} = 'list_cpan'},is_flag=>1,summary=>"Shortcu...
my $sc_metas = {};
my $copts = {format=>{default=>undef,description=>"\nOutput can be displayed in multiple formats, and a suitable default format is\nchosen depending on the application and/or whether output destination is\ninteractive terminal (i.e. whether output is...
my $r = {common_opts=>$copts};
# get words
my $shell;
my ($words, $cword);
if ($ENV{COMP_LINE}) { $shell = "bash"; require Complete::Bash; require Encode; ($words,$cword) = @{ Complete::Bash::parse_cmdline() }; ($words,$cword) = @{ Complete::Bash::join_wordbreak_words($words,$cword) }; $words = [map {Encode::decode("UTF-8",...
elsif ($ENV{COMMAND_LINE}) { $shell = "tcsh"; require Complete::Tcsh; ($words,$cword) = @{ Complete::Tcsh::parse_cmdline() }; }
@ARGV = @$words;
# strip program name
shift @$words; $cword--;
# parse common_opts which potentially sets subcommand
{
require Getopt::Long;
my $old_go_conf = Getopt::Long::Configure('pass_through', 'no_ignore_case', 'bundling', 'no_auto_abbrev', 'no_getopt_compat', 'gnu_compat');
my @go_spec;
for my $k (keys %$copts) { push @go_spec, $copts->{$k}{getopt} => sub { my ($go, $val) = @_; $copts->{$k}{handler}->($go, $val, $r); } }
Getopt::Long::GetOptions(@go_spec);
Getopt::Long::Configure($old_go_conf);
}
# select subcommand
my $scn = $r->{subcommand_name};
my $scn_from = $r->{subcommand_name_from};
if (!defined($scn) && defined($args->{default_subcommand})) {
# get from default_subcommand
if ($args->{get_subcommand_from_arg} == 1) {
$scn = $args->{default_subcommand};
$scn_from = "default_subcommand";
} elsif ($args->{get_subcommand_from_arg} == 2 && !@ARGV) {
$scn = $args->{default_subcommand};
script/_acme-cpanauthors view on Meta::CPAN
#}
#
#$SPEC{answer_num_entries} = {
# v => 1.1,
# summary => 'Get the number of entries in an answer',
# description => <<'_',
#
#It is equivalent to:
#
# ref $answer eq 'ARRAY' ? (@$answer // 0) : (@{$answer->{words}} // 0);
#
#_
# args => {
# %arg0_answer,
# },
# args_as => 'array',
# result_naked => 1,
# result => {
# schema => 'int*',
# },
#};
#sub answer_num_entries {
# my $ans = shift;
# return unless defined $ans;
# return ref($ans) eq 'HASH' ? (@{$ans->{words} // []} // 0) : (@$ans // 0);
#}
#
#$SPEC{answer_has_entries} = {
# v => 1.1,
# summary => 'Check if answer has entries',
# description => <<'_',
#
#It is equivalent to:
#
# ref $answer eq 'ARRAY' ? (@$answer ? 1:0) : (@{$answer->{words}} ? 1:0);
#
#_
# args => {
# %arg0_answer,
# },
# args_as => 'array',
# result_naked => 1,
# result => {
# schema => 'int*',
# },
#};
#sub answer_has_entries {
# my $ans = shift;
# return unless defined $ans;
# return ref($ans) eq 'HASH' ? (@{$ans->{words} // []} ? 1:0) : (@$ans ? 1:0);
#}
#
#sub __min(@) { ## no critic: Subroutines::ProhibitSubroutinePrototypes
# my $m = $_[0];
# for (@_) {
# $m = $_ if $_ < $m;
# }
# $m;
#}
#
#our $code_editdist;
#our $editdist_flex;
#
## straight copy of Wikipedia's "Levenshtein Distance"
#sub __editdist {
# my @a = split //, shift;
# my @b = split //, shift;
#
# # There is an extra row and column in the matrix. This is the distance from
# # the empty string to a substring of the target.
# my @d;
# $d[$_][0] = $_ for 0 .. @a;
# $d[0][$_] = $_ for 0 .. @b;
#
# for my $i (1 .. @a) {
# for my $j (1 .. @b) {
# $d[$i][$j] = (
# $a[$i-1] eq $b[$j-1]
# ? $d[$i-1][$j-1]
# : 1 + __min(
# $d[$i-1][$j],
# $d[$i][$j-1],
# $d[$i-1][$j-1]
# )
# );
# }
# }
#
# $d[@a][@b];
#}
#
#my %complete_array_elem_args = (
# %arg_word,
# array => {
# schema => ['array*'=>{of=>'str*'}],
# req => 1,
# pos => 1,
# slurpy => 1,
# },
# summaries => {
# schema => ['array*'=>{of=>'str*'}],
# },
# exclude => {
# schema => ['array*'],
# },
# replace_map => {
# schema => ['hash*', each_value=>['array*', of=>'str*']],
# description => <<'_',
#
#You can supply correction entries in this option. An example is when array if
#`['mount','unmount']` and `umount` is a popular "typo" for `unmount`. When
#someone already types `um` it cannot be completed into anything (even the
#current fuzzy mode will return *both* so it cannot complete immediately).
#
#One solution is to add replace_map `{'unmount'=>['umount']}`. This way, `umount`
#will be regarded the same as `unmount` and when user types `um` it can be
#completed unambiguously into `unmount`.
#
#_
# tags => ['experimental'],
# },
#);
#
#$SPEC{complete_array_elem} = {
# v => 1.1,
script/_acme-cpanauthors view on Meta::CPAN
# $re .= quotemeta($split_wordn[$i]).'\w*';
# }
# $re = qr/$re/;
# log_trace("[computil] Trying word-mode matching (re=%s) ...", $re) if $COMPLETE_UTIL_TRACE;
#
# for my $i (0..$#array) {
# my $match;
# {
# if ($arrayn[$i] =~ $re) {
# $match++;
# last;
# }
# # try splitting CamelCase into Camel-Case
# my $tmp = $array[$i];
# if ($tmp =~ s/([a-z0-9_])([A-Z])/$1-$2/g) {
# $tmp = uc($tmp) if $ci; $tmp =~ s/_/-/g if $map_case; # normalize again
# if ($tmp =~ $re) {
# $match++;
# last;
# }
# }
# }
# next unless $match;
# push @words, $array[$i];
# push @wordsumms, $arraysumms[$i] if $summaries;
# }
# log_trace("[computil] Result from word-mode matching: %s", \@words) if @words && $COMPLETE_UTIL_TRACE;
# }
#
# # prefix char-mode matching
# if ($char_mode && !@words && length($wordn) && length($wordn) <= 7) {
# my $re = join(".*", map {quotemeta} split(//, $wordn));
# $re = qr/\A$re/;
# log_trace("[computil] Trying prefix char-mode matching (re=%s) ...", $re) if $COMPLETE_UTIL_TRACE;
# for my $i (0..$#array) {
# if ($arrayn[$i] =~ $re) {
# push @words, $array[$i];
# push @wordsumms, $arraysumms[$i] if $summaries;
# }
# }
# log_trace("[computil] Result from prefix char-mode matching: %s", \@words) if @words && $COMPLETE_UTIL_TRACE;
# }
#
# # char-mode matching
# if ($char_mode && !@words && length($wordn) && length($wordn) <= 7) {
# my $re = join(".*", map {quotemeta} split(//, $wordn));
# $re = qr/$re/;
# log_trace("[computil] Trying char-mode matching (re=%s) ...", $re) if $COMPLETE_UTIL_TRACE;
# for my $i (0..$#array) {
# if ($arrayn[$i] =~ $re) {
# push @words, $array[$i];
# push @wordsumms, $arraysumms[$i] if $summaries;
# }
# }
# log_trace("[computil] Result from char-mode matching: %s", \@words) if @words && $COMPLETE_UTIL_TRACE;
# }
#
# # fuzzy matching
# if ($fuzzy && !@words) {
# log_trace("[computil] Trying fuzzy matching ...") if $COMPLETE_UTIL_TRACE;
# $code_editdist //= do {
# my $env = $ENV{COMPLETE_UTIL_LEVENSHTEIN} // '';
# if ($env eq 'xs') {
# require Text::Levenshtein::XS;
# $editdist_flex = 0;
# \&Text::Levenshtein::XS::distance;
# } elsif ($env eq 'flexible') {
# require Text::Levenshtein::Flexible;
# $editdist_flex = 1;
# \&Text::Levenshtein::Flexible::levenshtein_l;
# } elsif ($env eq 'pp') {
# $editdist_flex = 0;
# \&__editdist;
# } elsif (eval { require Text::Levenshtein::Flexible; 1 }) {
# $editdist_flex = 1;
# \&Text::Levenshtein::Flexible::levenshtein_l;
# } else {
# $editdist_flex = 0;
# \&__editdist;
# }
# };
#
# my $factor = 1.3;
# my $x = -1;
# my $y = 1;
#
# # note: we cannot use Text::Levenshtein::Flexible::levenshtein_l_all()
# # because we perform distance calculation on the normalized array but we
# # want to get the original array elements
#
# my %editdists;
# ELEM:
# for my $i (0..$#array) {
# my $eln = $arrayn[$i];
#
# for my $l (length($wordn)-$y .. length($wordn)+$y) {
# next if $l <= 0;
# my $chopped = substr($eln, 0, $l);
# my $maxd = __min(
# __min(length($chopped), length($word))/$factor,
# $fuzzy,
# );
# my $d;
# unless (defined $editdists{$chopped}) {
# if ($editdist_flex) {
# $d = $code_editdist->($wordn, $chopped, $maxd);
# next ELEM unless defined $d;
# } else {
# $d = $code_editdist->($wordn, $chopped);
# }
# $editdists{$chopped} = $d;
# } else {
# $d = $editdists{$chopped};
# }
# #say "D: d($word,$chopped)=$d (maxd=$maxd)";
# next unless $d <= $maxd;
# push @words, $array[$i];
# push @wordsumms, $arraysumms[$i] if $summaries;
# next ELEM;
# }
# }
# log_trace("[computil] Result from fuzzy matching: %s", \@words) if @words && $COMPLETE_UTIL_TRACE;
# }
#
# # replace back the words from replace_map
# if ($rmapn && @words) {
# my @wordsn;
# for my $el (@words) {
# my $eln = $ci ? uc($el) : $el; $eln =~ s/_/-/g if $map_case;
# push @wordsn, $eln;
# }
# for my $i (0..$#words) {
# if (my $w = $rev_rmapn->{$wordsn[$i]}) {
# $words[$i] = $w;
# }
# }
# }
#
# # sort results and insert summaries
# $res = [
# map {
# $summaries ?
# {word=>$words[$_], summary=>$wordsumms[$_]} :
# $words[$_]
# }
# sort {
# $ci ?
# lc($words[$a]) cmp lc($words[$b]) :
# $words[$a] cmp $words[$b] }
# 0 .. $#words
# ];
#
# RETURN_RES:
# log_trace("[computil] leaving complete_array_elem(), res=%s", $res)
# if $COMPLETE_UTIL_TRACE;
# $res;
#}
#
#$SPEC{complete_hash_key} = {
# v => 1.1,
# summary => 'Complete from hash keys',
# args => {
# %arg_word,
# hash => { schema=>['hash*'=>{}], req=>1 },
# summaries => { schema=>['hash*'=>{}] },
# summaries_from_hash_values => { schema=>'true*' },
# },
# result_naked => 1,
# result => {
# schema => 'array',
# },
# args_rels => {
# choose_one => ['summaries', 'summaries_from_hash_values'],
( run in 0.308 second using v1.01-cache-2.11-cpan-13bb782fe5a )