#!perl

our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2020-06-02'; # DATE
our $DIST = 'Games-Hangman'; # DIST
our $VERSION = '0.063'; # VERSION

use Games::Hangman;
use Getopt::Long::More;

my %opts = (
    list => undef,
    min_len => undef,
    max_len => undef,
);
GetOptions(
    'wordlist|list|l|w=s' => optspec(
        destination => \$opts{list},
        completion => sub {
            require Complete::Module;
            my %cargs = @_;
            Complete::Module::complete_module(
                word => $cargs{word},
                ns_prefix => 'WordList',
            );
        },
    ),
    'min-len=i' => \$opts{min_len},
    'max-len=i' => \$opts{max_len},
);

binmode(STDOUT, ":encoding(utf8)");
my $game = Games::Hangman->new(%opts);
$game->run;

# ABSTRACT: A text-based hangman
# PODNAME: hangman

__END__

=pod

=encoding UTF-8

=head1 NAME

hangman - A text-based hangman

=head1 VERSION

This document describes version 0.063 of hangman (from Perl distribution Games-Hangman), released on 2020-06-02.

=head1 SYNOPSIS

 % hangman
 % hangman -l Proverb::TWW; # select specific word-/phraselist

 % hangman --help
 % hangman --version

Example of game display:

    ____
   |    |      Phrase #:    2
   |    o      Guessed : abcmtwxyz
   |   /|\     Average :  50%
   |    |
   |   /
  _|_
 |   |______
 |          |
 |__________|

 List  : Proverb::TWW
 Phrase: A--'- w--- t-at ---- w---.
 Guess :

=head1 DESCRIPTION

This is yet another text-based implementation of the popular word game Hangman.
In Hangman, you guess a word letter-by-letter. There is a maximum of seven wrong
guesses. Each wrong guess will incrementally draw a figure of a man being hung.
What's different about this particular variant:

=over

=item * Longer phrases are allowed

=item * Wordlists (or phrase list) are searched from C<WordList::*> modules

=back

=head1 OPTIONS

=head2 C<--list=s, -l>

Select word-/phraselist, will be searched in C<Wordlist::*> or
C<WordList::Phrase::>.

=head2 C<--wordlist=s, -w>

Alias for C<--wordlist>.

=head2 C<--min-len=i>

Minimum word/phrase length. The default is 5 for word, 0 for phrase.

=head2 C<--max-len=i>

Maximum word/phrase length. The default is unlimited.

=head1 COMPLETION

This script has shell tab completion capability with support for several
shells.

=head2 bash

To activate bash completion for this script, put:

 complete -C hangman hangman

in your bash startup (e.g. C<~/.bashrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.

It is recommended, however, that you install modules using L<cpanm-shcompgen>
which can activate shell completion for scripts immediately.

=head2 tcsh

To activate tcsh completion for this script, put:

 complete hangman 'p/*/`hangman`/'

in your tcsh startup (e.g. C<~/.tcshrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.

It is also recommended to install C<shcompgen> (see above).

=head2 other shells

For fish and zsh, install C<shcompgen> as described above.

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/Games-Hangman>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-Games-Hangman>.

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Games-Hangman>

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.

=head1 SEE ALSO

hangman from C<bsdgames> Debian package

hangman from C<ppt> (Perl Power Tools) on CPAN

C<WordList::*>

=head1 AUTHOR

perlancar <perlancar@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2020, 2016, 2015, 2014 by 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.

=cut
