App-wordlist
view release on metacpan or search on metacpan
script/wordlist view on Meta::CPAN
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
package main;
use 5.010001;
use strict;
#use warnings;
# load modules
### declare global variables
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2025-03-07'; # DATE
our $DIST = 'App-wordlist'; # DIST
our $VERSION = '0.295'; # VERSION
my $_pci_metas = {""=>{args=>{action=>{cmdline_aliases=>{L=>{code=>sub{"DUMMY"},is_flag=>1,summary=>"List WordList::* modules on CPAN"},l=>{code=>sub{"DUMMY"},is_flag=>1,summary=>"List installed WordList::* modules"},s=>{code=>sub{"DUMMY"},is_flag=>1...
our $_pci_log_outputs = {};
our $_pci_meta_result_stream = 0;
our $_pci_meta_result_type;
our $_pci_meta_result_type_is_simple;
our $_pci_meta_skip_format = 0;
our $_pci_r = {naked_res=>0,read_config=>1,read_env=>1,subcommand_name=>""};
our %_pci_args;
### begin code_before_enable_logging
### end code_before_enable_logging
### enable logging
$_pci_log_outputs->{Screen} = { conf => { colorize_tags => 1, formatter => sub { "wordlist: " . $_[0] } } };
#### begin code_add_extra_log_outputs
#### end code_add_extra_log_outputs
require Log::ger::Output; Log::ger::Output->set("Composite", outputs => $_pci_log_outputs);
require Log::ger; Log::ger->import;
### begin code_after_enable_logging
### end code_after_enable_logging
### declare subroutines
sub _pci_err {
my $res = shift;
print STDERR "ERROR $res->[0]: $res->[1]\n";
exit $res->[0]-300;
}
sub _pci_json {
state $json = do {
if (eval { require JSON::XS; 1 }) { JSON::XS->new->canonical(1)->allow_nonref }
else { require JSON::PP; JSON::PP->new->canonical(1)->allow_nonref }
};
$json;
}
### begin code_before_parse_cmdline_options
### end code_before_parse_cmdline_options
### get arguments (from config file, env, command-line args
{
my %mentioned_args;
require Getopt::Long::EvenLess;
log_trace("Parsing command-line arguments ...");
my $go_spec1 = {
'config-path=s@' => sub { $_pci_r->{config_paths} //= []; push @{ $_pci_r->{config_paths} }, $_[1]; },
'config-profile=s' => sub { $_pci_r->{config_profile} = $_[1]; },
'debug' => sub { require Log::ger::Util; Log::ger::Util::set_level("debug"); $_pci_r->{log_level} = "debug"; },
'format=s' => sub { $_pci_r->{format} = $_[1]; },
'help|h|?' => sub { print "wordlist - Grep words from (or test them against) WordList::*\n\nUsage:\n wordlist --help (or -h, -?)\n wordlist --version (or -v)\n wordlist [--action=str|-L|-l|-s|-t] [--chars-ordered=str]\n [--chars-unordered=s...
'json' => sub { $_pci_r->{format} = (-t STDOUT) ? "json-pretty" : "json"; ## no critic InputOutput::ProhibitInteractiveTest
},
'log-level=s' => sub { if ($_[1] eq "trace") { require Log::ger::Util; Log::ger::Util::set_level("trace"); Log::ger::Output::Composite::set_level("trace") } if ($_[1] eq "debug") { require Log::ger::Util; Log::ger::Util::set_level("debug"); Log::...
'naked-res' => sub { $_pci_r->{naked_res} = 1; },
'no-config' => sub { $_pci_r->{read_config} = 0; },
'no-env' => sub { $_pci_r->{read_env} = 0; },
'no-naked-res|nonaked-res' => sub { $_pci_r->{naked_res} = 0; },
'page-result:s' => sub { $_pci_r->{page_result} = 1; },
'quiet' => sub { require Log::ger::Util; Log::ger::Util::set_level("error"); $_pci_r->{log_level} = "error"; },
'trace' => sub { require Log::ger::Util; Log::ger::Util::set_level("trace"); $_pci_r->{log_level} = "trace"; },
script/wordlist view on Meta::CPAN
["list_cpan","list_installed","list_selected","grep","stat","test"]
Action C<list_installed> (shortcut option C<-l>) will list WordList::* modules
installed on the local system.
Action C<list_cpan> (shortcut option C<-L>) will list available WordList::*
modules on CPAN, either by querying the MetaCPAN site or by querying a local
mini CPAN using L<App::lcpan>.
Action C<list_selected> (option C<--action=list_selected>) will list the selected
WordList::* modules (e.g. via C<-w> or C<-b>).
Action C<grep> (the default action) will filter the words from each selected
wordlists and print them.
Action C<stat> (shortcut option C<-s>) will show statistics about all the selected
wordlists.
Action C<test> (shortcut option C<-t>) will check whether words are in one of the
wordlist, using C<word_exists()> method on each wordlist.
=item B<--color>=I<s>
When to highlight search string/matching pattern with color.
Default value:
"auto"
Valid values:
["never","always","auto"]
=item B<--detail>
Display more information when listing modules/result.
When listing installed modules (C<-l>), this means also returning a wordlist's
language.
When returning grep result, this means also returning wordlist name.
=item B<--lcpan>
Use local CPAN mirror first when available (for -L).
=item B<--num>=I<s>, B<-n>
Return (at most) this number of words (0 = unlimited).
Default value:
0
=item B<--random>, B<-r>
Pick random words.
If set to true, then streaming will be turned off. All words will be gathered
first, then words will be chosen randomly from the gathered list.
=item B<-l>
List installed WordList::* modules.
See C<--action>.
=item B<-L>
List WordList::* modules on CPAN.
See C<--action>.
=item B<-s>
Show statistics contained in the wordlist modules.
See C<--action>.
=item B<-t>
Test whether words exists in wordlist.
See C<--action>.
=back
=head2 Configuration options
=over
=item B<--config-path>=I<s>
Set path to configuration file.
Can actually be specified multiple times to instruct application to read from
multiple configuration files (and merge them).
Can be specified multiple times.
=item B<--config-profile>=I<s>
Set configuration profile to use.
A single configuration file can contain profiles, i.e. alternative sets of
values that can be selected. For example:
[profile=dev]
username=foo
pass=beaver
[profile=production]
username=bar
pass=honey
When you specify C<--config-profile=dev>, C<username> will be set to C<foo> and
C<password> to C<beaver>. When you specify C<--config-profile=production>,
script/wordlist view on Meta::CPAN
#}
#
#sub _word_has_chars_ordered {
# my ($word, $chars, $ci) = @_;
#
# if ($ci) {
# $word = lc $word;
# $chars = lc $chars;
# }
#
# my $last_index;
# for my $i (0..length($chars)-1) {
# my $char = substr($chars, $i, 1);
# my $index = index($word, $char);
# return 0 if $index < 0;
# return 0 if defined $last_index && $index < $last_index;
# $last_index = $index;
# $word =~ s/\Q$char\E//;
# }
# 1;
#}
#
#$SPEC{wordlist} = {
# v => 1.1,
# summary => 'Grep words from (or test them against) WordList::*',
# args => {
# arg => {
# schema => ['array*' => of => 'str*'],
# pos => 0,
# greedy => 1,
# tags => ['category:word-filtering'],
# },
# ignore_case => {
# schema => 'bool',
# default => 1,
# cmdline_aliases => {i=>{}},
# tags => ['category:word-filtering'],
# },
# len => {
# schema => 'int*',
# tags => ['category:word-filtering'],
# },
# min_len => {
# schema => 'int*',
# tags => ['category:word-filtering'],
# },
# max_len => {
# schema => 'int*',
# tags => ['category:word-filtering'],
# },
# num => {
# summary => 'Return (at most) this number of words (0 = unlimited)',
# schema => ['int*', min=>0, max=>9999],
# default => 0,
# cmdline_aliases => {n=>{}},
# },
# random => {
# summary => 'Pick random words',
# description => <<'_',
#
#If set to true, then streaming will be turned off. All words will be gathered
#first, then words will be chosen randomly from the gathered list.
#
#_
# schema => 'bool*',
# cmdline_aliases => {r=>{}},
# },
#
# %argspecopt_wordlists,
# %argspecopt_wordlist_bundles,
#
# %argspecsopt_exclude_wordlist,
#
# or => {
# summary => 'Instead of printing words that must match all queries (the default), print words that match any query',
# schema => 'bool',
# tags => ['category:word-filtering'],
# },
# action => {
# schema => ['str*', {
# in=>[
# 'list_cpan',
# 'list_installed',
# 'list_selected',
# 'grep',
# 'stat',
# 'test',
# ],
# 'x.in.summaries' => [
# 'List WordList::* modules on CPAN',
# 'List WordList::* modules installed locally',
# 'List WordList::* that are selected for use',
# 'Grep words from selected WordList::* modules',
# 'Show statistics for each selected WordList::* modules',
# 'Test words against selected WordList::* modules',
# ],
# }],
# default => 'grep',
# cmdline_aliases => {
# l => {
# summary=>'List installed WordList::* modules',
# is_flag => 1,
# code => sub { my $args=shift; $args->{action} = 'list_installed' },
# },
# L => {
# summary=>'List WordList::* modules on CPAN',
# is_flag => 1,
# code => sub { my $args=shift; $args->{action} = 'list_cpan' },
# },
# s => {
# summary=>'Show statistics contained in the wordlist modules',
# is_flag => 1,
# code => sub { my $args=shift; $args->{action} = 'stat' },
# },
# t => {
# summary=>'Test whether words exists in wordlist',
# is_flag => 1,
# code => sub { my $args=shift; $args->{action} = 'test' },
# },
# },
# description => <<'_',
( run in 0.739 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )