#!perl

# ABSTRACT: command line utility that return emails from file or url

package getemails;
$getemails::VERSION = '0.02';


use strict;
use warnings;
use Email::Extractor;
use feature 'say';
use Data::Dumper;

die "Usage: $0 <url>\n" unless @ARGV >= 1;

my $params = {
    uri            => $ARGV[0],
    check_contacts => $ARGV[1],
    verbose        => $ARGV[2]
};

# warn Dumper $params;

my $crawler = Email::Extractor->new( verbose => $params->{verbose} );
my $a =
  $crawler->search_until_attempts( $params->{uri}, $params->{check_contacts} );
print "$_\n" for @$a;
print "Links checked sum-total: " . $crawler->{last_attempts} . "\n"
  if ( $params->{verbose} && $params->{check_contacts} > 1 );

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

getemails - command line utility that return emails from file or url

=head1 VERSION

version 0.02

=head1 SYNOPSIS

    getemails http://example.com
    getemails http://example.com 0 v

second parameter is to check or not to check contact links

You can set this number to any integer and it will set value of $attempts at L<Email::Extractor/search_until_attempts>

v - verbose mode

By default it checks contact links in all available languages at L<Email::Extractor/contacts>

=head1 AUTHOR

Pavel Serikov <pavelsr@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2018 by Pavel Serikov.

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
