#!/usr/bin/perl

# ABSTRACT: provide a web interface to a Pinto repository
# PODNAME: pinto-server

use strict;
use warnings;

use Pod::Usage;
use Getopt::Long;

use Pinto::Server;

#-----------------------------------------------------------------------------

our $VERSION = '0.026'; # VERSION

#-----------------------------------------------------------------------------

my @opt_spec = qw(daemon port=i repos|r=s);
GetOptions(\my %opts, @opt_spec) or pod2usage();

$opts{repos} ||= $ENV{PINTO_REPOSITORY};
pod2usage(-message => 'Must specify a repository') if not $opts{repos};

Pinto::Server->new(%opts)->run();

#----------------------------------------------------------------------------



=pod

=for :stopwords Jeffrey Ryan Thalhammer Imaginative Software Systems

=head1 NAME

pinto-server - provide a web interface to a Pinto repository

=head1 VERSION

version 0.026

=head1 SYNOPSIS

  pinto-server --repos=/path/to/repository [--daemon] [--port=N]

=head1 DESCRIPTION

Before running L<pinto-server> you must first create a Pinto
repository.  See L<pinto-admin> for instructions on that.

L<pinto-server> provides a web API to a L<Pinto> repository.  Remote
clients (like L<pinto-remote>) can use this API to add distributions,
remove packages, and list the contents of the Pinto repository.  In
addition, L<pinto-server> exposes the contents of your repository, so
you can use it as the source of distributions for L<cpan> or L<cpanm>.

=head1 ARGUMENTS

=over 4

=item --repos=PATH

The path to the Pinto repository you wish to serve.

=back

=head1 OPTIONS

=over 4

=item --daemon

Tells L<pinto-server> to fork and run in a separate process.

=item --port=N

Sets the port number for the server to listen on.  Default is 3000.

=back

=head1 DEPLOYMENT

L<pinto-server> can be run as a stand-alone server as shown in the
L</"SYNOPSIS">.  However, this may not perform well under heavy load.

L<pinto-server> is also PSGI compatible, so if you need a more
powerful robust server, you can run it under L<Plack> like this:

  $> plackup [OPTIONS] /path/to/pinto-server

=head1 CAVEATS

If you are running L<pinto-server> and have configured L<Pinto> to use
a VCS-based store, such as L<Pinto::Store::VCS::Svn> or
L<Pinto::Store::VCS::Git>, then you must not mess with the VCS
directly (at least not the part of the VCS that holds the Pinto
repository).  This is because L<pinto-server> only initializes the
working copy of the repository at startup.  Thereafter, it assumes
that it is the only actor affecting the Pinto repository within the
VCS.  If you start modifying Pinto's area of the VCS directly, then
the working copy for L<pinto-server> will become out of date and
conflicts will happen.

=head1 LIMITATIONS

L<pinto-server> speaks HTTP, but does not actually serve HTML.  At the
moment, it is geared toward command line tools like L<pinto-remote> so
it just returns plain text.  This will probably change as
L<pinto-server> evolves into a real web application.

=head1 AUTHOR

Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Imaginative Software Systems.

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


__END__


