App-gist
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/App/gist.pm view on Meta::CPAN
package App::gist;
$App::gist::VERSION = '0.16';
use strict;
use warnings;
use base qw(App::Cmd::Simple);
use Pithub::Gists;
use File::Basename;
use Class::Load qw(try_load_class);
BEGIN {
package App::gist::Auth;
$App::gist::Auth::VERSION = '0.16';
use Moo::Role;
use Pithub::Base;
around _request_for => sub {
my ($orig, $self, @args) = @_;
my $req = $self -> $orig(@args);
my ($login, $passwd) = App::gist::_get_credentials();
$req -> headers -> remove_header('Authorization');
$req -> headers -> authorization_basic($login, $passwd);
return $req;
};
'Moo::Role' -> apply_roles_to_package(
'Pithub::Base',
'App::gist::Auth'
);
};
=head1 NAME
App::gist - Gist command-line tool
=head1 VERSION
version 0.16
=head1 SYNOPSIS
$ gist script.pl
=cut
sub opt_spec {
return (
['description|d=s', 'set the description for the gist' ],
['name|n=s', 'specify the name of the file' ],
['update|u=s', 'update the given gist with the given file'],
['private|p', 'create a private gist' ],
['web|w', 'only output the web url' ]
);
}
sub validate_args {
my ($self, $opt, $args) = @_;
$self -> usage_error("Too few arguments.")
unless %$opt || @$args || ! -t STDIN;
}
sub execute {
my ($self, $opt, $args) = @_;
my $id = $opt -> {'update'};
my $file = $args -> [0];
my $description = $opt -> {'description'};
my $public = $opt -> {'private'} ? 0 : 1;
my $web = $opt -> {'web'} ? 1 : 0;
my ($name, $data);
if ($file) {
open my $fh, '<', $file or die "Err: Enter a valid file name.\n";
$data = join('', <$fh>);
close $fh;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.350 second using v1.00-cache-2.02-grep-82fe00e-cpan-f73e49a70403 )