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"; },
'verbose' => sub { require Log::ger::Util; Log::ger::Util::set_level("info" ); $_pci_r->{log_level} = "info" ; },
'version|v' => sub { no warnings 'once'; require App::wordlist::wordle; print "wordlist-wordle version ", "0.295", ($App::wordlist::wordle::DATE ? " ($App::wordlist::wordle::DATE)" : ''), "\n"; print " Generated by Perinci::CmdLine::Inline versi...
};
my $go_spec2 = {
'D' => sub { $_pci_args{'exclude_dynamic_wordlists'} = $_[1];
},
'P=s' => sub { $_pci_args{'exclude_wordlist_pattern'} = $_[1];
},
'X=s@' => sub { if ($mentioned_args{'exclude_wordlists'}++) { push @{ $_pci_args{'exclude_wordlists'} }, $_[1] } else { $_pci_args{'exclude_wordlists'} = [$_[1]] }
},
'arg-json=s' => sub { $_pci_args{'arg'} = _pci_json()->decode($_[1]);
},
'arg=s@' => sub { if ($mentioned_args{'arg'}++) { push @{ $_pci_args{'arg'} }, $_[1] } else { $_pci_args{'arg'} = [$_[1]] }
},
'b=s@' => sub { if ($mentioned_args{'wordlist_bundles'}++) { push @{ $_pci_args{'wordlist_bundles'} }, $_[1] } else { $_pci_args{'wordlist_bundles'} = [$_[1]] }
},
'color=s' => sub { $_pci_args{'color'} = $_[1];
},
'config-path=s@' => sub { },
'config-profile=s' => sub { },
'debug' => sub { },
'detail' => sub { $_pci_args{'detail'} = $_[1];
},
'exclude-dynamic-wordlists' => sub { $_pci_args{'exclude_dynamic_wordlists'} = $_[1];
},
'exclude-wordlist-pattern=s' => sub { $_pci_args{'exclude_wordlist_pattern'} = $_[1];
},
'exclude-wordlist=s@' => sub { if ($mentioned_args{'exclude_wordlists'}++) { push @{ $_pci_args{'exclude_wordlists'} }, $_[1] } else { $_pci_args{'exclude_wordlists'} = [$_[1]] }
},
'exclude-wordlists-json=s' => sub { $_pci_args{'exclude_wordlists'} = _pci_json()->decode($_[1]);
},
'format=s' => sub { },
'help|h|?' => sub { },
'i' => sub { $_pci_args{'ignore_case'} = $_[1];
},
'ignore-case' => sub { $_pci_args{'ignore_case'} = $_[1];
},
'include-dynamic-wordlists' => sub { $_pci_args{'exclude_dynamic_wordlists'} = 0;
},
'json' => sub { },
'lang=s@' => sub { if ($mentioned_args{'langs'}++) { push @{ $_pci_args{'langs'} }, $_[1] } else { $_pci_args{'langs'} = [$_[1]] }
},
'langs-json=s' => sub { $_pci_args{'langs'} = _pci_json()->decode($_[1]);
},
'len=s' => sub { $_pci_args{'len'} = $_[1];
},
'log-level=s' => sub { },
'max-len=s' => sub { $_pci_args{'max_len'} = $_[1];
},
'min-len=s' => sub { $_pci_args{'min_len'} = $_[1];
script/wordlist-wordle view on Meta::CPAN
if ($_pci_r->{page_result} // $ENV{PAGE_RESULT} // $_pci_r->{res}[3]{"cmdline.page_result"}) {
my $pager = $_pci_r->{pager} // $_pci_r->{res}[3]{"cmdline.pager"} // $ENV{PAGER} // "less -FRSX";
open $fh, "| $pager"; ## no critic InputOutput::ProhibitTwoArgOpen
} else {
$fh = \*STDOUT;
}
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 : 1;
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 $fh $l; print $fh "\n" unless $_pci_meta_result_type eq "...
} else {
print $fh $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
wordlist-wordle - Help solve Wordle
=head1 VERSION
This document describes version 0.295 of main::_DataPacker (from Perl distribution App-wordlist-wordle), released on 2025-03-07.
=head1 SYNOPSIS
B<wordlist-wordle> B<L<--help|/"--help, -h, -?">> (or B<L<-h|/"--help, -h, -?">>, B<L<-?|/"--help, -h, -?">>)
B<wordlist-wordle> B<L<--version|/"--version, -v">> (or B<L<-v|/"--version, -v">>)
B<wordlist-wordle> [B<L<--color|/"--color=s">>=I<str>] [(B<L<--config-path|/"--config-path=s">>=I<path>)+|B<L<--no-config|/"--no-config">>] [B<L<--config-profile|/"--config-profile=s">>=I<profile>] [B<L<--debug|/"--debug">>|B<L<--log-level|/"--log-le...
See examples in the L</EXAMPLES> section.
=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).
script/wordlist-wordle view on Meta::CPAN
You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.
You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...
You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...
To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:
[plugin=DumpArgs]
-event=before_validate_args
-prio=99
[plugin=Foo]
-event=after_validate_args
arg1=val1
arg2=val2
which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.
List of available configuration parameters:
arg (see --arg)
color (see --color)
detail (see --detail)
exclude_dynamic_wordlists (see --exclude-dynamic-wordlists)
exclude_wordlist_pattern (see --exclude-wordlist-pattern)
exclude_wordlists (see --exclude-wordlist)
format (see --format)
ignore_case (see --no-ignore-case)
langs (see --lang)
len (see --len)
log_level (see --log-level)
max_len (see --max-len)
min_len (see --min-len)
naked_res (see --naked-res)
num (see --num)
or (see --or)
random (see --random)
wordlist_bundles (see --wordlist-bundle)
wordlists (see --wordlist)
=head1 ENVIRONMENT
=head2 WORDLIST_WORDLE_OPT
String. Specify additional command-line options.
=head1 FILES
=head2 ~/.config/wordlist-wordle.conf
=head2 ~/wordlist-wordle.conf
=head2 /etc/wordlist-wordle.conf
=head1 EXAMPLES
=head2 One guess
% wordlist-wordle cR^eEk
=head2 Five guesses
% wordlist-wordle A^R^isE^ Pound might blA^ck PR^ivY^
=head1 HOMEPAGE
Please visit the project's homepage at L<https://metacpan.org/release/App-wordlist-wordle>.
=head1 SOURCE
Source repository is at L<https://github.com/perlancar/perl-App-wordlist-wordle>.
=head1 AUTHOR
perlancar <perlancar@cpan.org>
=head1 CONTRIBUTING
To contribute, you can send patches by email/via RT, or send pull requests on
GitHub.
Most of the time, you don't need to build the distribution yourself. You can
simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally on your
system), you can install L<Dist::Zilla>,
L<Dist::Zilla::PluginBundle::Author::PERLANCAR>,
L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond
that are considered a bug and can be reported to me.
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2025 by perlancar <perlancar@cpan.org>.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=head1 BUGS
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=App-wordlist-wordle>
When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.
=cut
__DATA__
Data::Section::Seekable v1
Clone/PP.pm,20,6331,0;0
Complete/Bash.pm,6376,41736,1;193
Config/IOD/Base.pm,48139,25293,2;1496
Config/IOD/Reader.pm,73461,18862,3;2351
Data/Check/Structure.pm,92355,9787,4;2955
Data/Sah/Normalize.pm,102172,9190,5;3311
Data/Sah/Resolve.pm,111390,12880,6;3593
Data/Sah/Type/BaseType.pm,124304,6218,7;3989
( run in 0.538 second using v1.01-cache-2.11-cpan-f52f0507bed )