App-wordlist-wordle
view release on metacpan or search on metacpan
script/wordlist-wordle 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-wordle'; # DIST
our $VERSION = '0.295'; # VERSION
my $_pci_metas = {""=>{args=>{arg=>{greedy=>1,pos=>0,schema=>["array",{of=>["str",{req=>1}],req=>1}],tags=>["category:word-filtering"]},color=>{default=>"auto",schema=>["str",{in=>["never","always","auto"],req=>1,"x.in.summaries"=>["Never show color"...
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-wordle: " . $_[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-wordle - Help solve Wordle\n\nUsage:\n wordlist-wordle --help (or -h, -?)\n wordlist-wordle --version (or -v)\n wordlist-wordle [--color=str] [(--config-path=path)+|--no-config]\n [--config-profile=profil...
'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-wordle view on Meta::CPAN
=head1 DESCRIPTION
This is a wrapper to L<wordlist> designed to be a convenient helper to solve
Wordle puzzle. By default it greps from the C<EN::Wordle> wordlist. It accepts
a series of guesses in a format like the following:
A^R^isE^
Pound
might
blA^ck
PR^ivY^
where lowercase means wrong guess, uppercase means correct letter and position,
while (uppercase) letter followed by a caret (C<^>) means the letter exists in
another position. It will convert these guesses to regex patterns and the
C<--chars-unordered> option and pass it to C<wordlist>.
=head1 OPTIONS
C<*> marks required options.
=head2 Main options
=over
=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<--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.
=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>,
C<username> will be set to C<bar> and C<password> to C<honey>.
=item B<--no-config>
Do not use any configuration file.
If you specify C<--no-config>, the application will not read any configuration
file.
=back
=head2 Environment options
=over
=item B<--no-env>
Do not read environment for default options.
If you specify C<--no-env>, the application wil not read any environment
variable.
( run in 1.189 second using v1.01-cache-2.11-cpan-140bd7fdf52 )