#!/usr/bin/env perl

use strict;
use warnings;
use 5.008_001;

use Pod::Usage;

use version; our $VERSION = 'v0.5.3';

use App::Memcached::CLI::Main;

if (__FILE__ eq $0) {
    main()
} else {
    return 1;
}

sub main {
    my $Cli_Class = 'App::Memcached::CLI::Main';
    my $params = $Cli_Class->parse_args;
    pod2usage(-verbose => 1) if $params->{help};
    pod2usage(-verbose => 2) if $params->{man};
    my $cli = $Cli_Class->new(%$params) or pod2usage(-verbose => 1);
    $cli->run;
}

__END__

=encoding utf-8

=head1 NAME

B<memcached-cli> - Interactive/Batch CLI for Memcached

=head1 SYNOPSIS

Run an interactive CLI:

    memcached-cli <host[:port] | /path/to/socket> [options]

    # Without 1st arg, connects 127.0.0.1:11211 by default
    memcached-cli [options]
    # You can provide <addr> by option style
    memcached-cli --addr|-a <host[:port] | /path/to/socket> [options]

These above turns into interactive mode like below:

    memcached@SERVER:PORT>
    memcached@SERVER:PORT> \h    # show help
    memcached@SERVER:PORT> \d    # display slabs info

Run as batch script:

    memcached-cli [options] <command> [<args>]

Show Help/Manual:

    # For general usage
    memcached-cli -h|--help
    memcached-cli --man

    # For available commands
    memcached-cli help
    memcached-cli help <command>

=head1 DESCRIPTION

This script runs an interactive CLI or batch utility for Memcached.

In interactive mode, it connects to a specified Memcached server and
interactively executes each command you run.

In batch mode, you can execute any command which you can do in interactive mode.

=head1 OPTIONS

=over 4

=item B<-t|--timeout=Int>

Sets connection timeout. Default is 1 seconds.

=item B<-d|--debug>

Shows debug logs.

=back

=head1 SEE ALSO

L<App::Memcached::CLI::Main>,
B<memcached(1)>,
L<http://www.memcached.org/>

=head1 AUTHORS

YASUTAKE Kiyoshi E<lt>yasutake.kiyoshi@gmail.comE<gt>

=head1 LICENSE

Copyright (C) 2015 YASUTAKE Kiyoshi.

This library is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.  That means either (a) the GNU General Public
License or (b) the Artistic License.

=cut

