#!/usr/bin/perl

use App::gist;

use Getopt::Long;

use strict;
use warnings;

=head1 NAME

gist - GitHub Gist creator

=head1 VERSION

version 0.06

=cut

=head1 SYNOPSIS

 gist [OPTIONS] FILE

 Options:
   --description, -d  DESCRIPTION
   --update, -u       GIST_ID
   --private, -p

 Examples:
   $ gist script.pl
   $ cat script | gist

=cut

my %args;

GetOptions(\%args,
	'update=s',
	'private',
	'description=s'
);

my $app = App::gist -> new(\%args, @ARGV);

my $gist = $app -> run;

print "Gist " . $gist -> {'id'} . " successfully created.\n";
print "Web URL: " . $gist -> {'html_url'} . "\n";
print "Public Clone URL: " . $gist -> {'git_pull_url'} . "\n"
	unless $app -> {'private'};
print "Private Clone URL: " . $gist -> {'git_push_url'} . "\n";

=head1 OPTIONS

=over 4

=item B<--description>, B<-d> DESCRIPTION

Set the description for the gist.

=item B<--update>, B<-u> GIST_ID

Update the given gist (identified by GIST_ID), with the given file.

=item B<--private>, B<-p>

Create a private gist.

=back

=head1 CONFIGURATION

The login username and the password can be set via the GITHUB_USER and
GITHUB_PASSWD environment variables. If not set, will be used the
values of C<github.user> and C<github.password> from the Git configuration.

To set them, type:

    $ git config --global github.user LoginName
    $ git config --global github.password GitHubPassword

If C<github.user> or C<github.password> are not set, the login name and
the password will be asked interactively to the user.

=head1 AUTHOR

Alessandro Ghedini <alexbio@cpan.org>

=head1 LICENSE AND COPYRIGHT

Copyright 2011 Alessandro Ghedini.

This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

=cut
