App-Nopaste
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/App/Nopaste/Command.pm view on Meta::CPAN
sub filename {
my $self = shift;
my @files = @{ $self->extra_argv };
return undef unless @files;
return undef if $self->paste or $files[0] eq '-';
return $files[0];
}
sub run {
my $self = shift;
if ($self->list_services) {
for (sort App::Nopaste->plugins) {
s/App::Nopaste::Service::(\w+)$/$1/;
print $_, "\n";
}
exit 0;
}
my $text = $self->read_text;
utf8::decode($text);
my %args = map { $_ => $self->$_ } @acc, qw(filename);
$args{text} ||= $text;
$args{error_handler} = $args{warn_handler} = sub { }
if $self->quiet;
my $url = App::Nopaste->nopaste(%args);
if ($self->copy) {
use_module('Clipboard')->import;
eval {
Clipboard->copy_to_all_selections($url);
1;
} or Clipboard->copy($url);
}
if ($self->open_url) {
use_module('Browser::Open');
Browser::Open::open_browser($url);
}
return $url;
}
sub read_text {
my $self = shift;
if ($self->paste && @{ $self->extra_argv }) {
die "You may not specify --paste and files simultaneously.\n";
}
if ($self->paste) {
use_module('Clipboard')->import;
return Clipboard->paste;
}
local @ARGV = @{ $self->extra_argv };
local $/;
return <>;
}
1;
__END__
=pod
=encoding UTF-8
=for stopwords chan desc lang nopaste pastebot
=head1 NAME
App::Nopaste::Command - command-line utility for L<App::Nopaste>
=head1 VERSION
version 1.013
=head1 DESCRIPTION
This application will take some text on STDIN and give you a URL on STDOUT.
You may also specify files as arguments, they will be concatenated together
into one large nopaste.
=head1 OPTIONS
=head2 -d, --desc
The one line description of your paste. The default is usually the first few
characters of your text.
=head2 -n, --name
Your nickname, usually displayed with the paste. Default: C<$NOPASTE_NICK> then
C<$USER>.
=head2 -l, --lang
The language of the nopaste. The values accepted depend on the nopaste service.
There is no mapping done yet. Default: perl.
=head2 -c, --chan
The channel for the nopaste, not always relevant. Usually tied to a pastebot in that channel which will announce your paste.
=head2 -s, --services
The nopaste services to try, in order. You may also specify this in C<$NOPASTE_SERVICES> (space-separated list of service names, e.g. C<Shadowcat Gist>).
=head2 -L, --list
List available nopaste services.
=head2 -x, --copy
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.829 second using v1.00-cache-2.02-grep-82fe00e-cpan-9e6bc14194b )