summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-05-30 07:19:40 -0500
committerJesse Luehrs <doy@tozt.net>2013-05-30 07:20:37 -0500
commit8df94620704fd56e5d0f718223f2b195181f57b6 (patch)
tree692b605edbe6e17d49fef9aede7e750eb6b357b8
parenta3dcdb0d05d46a48e9305a34c4d4e0b954d50d9b (diff)
downloadreply-8df94620704fd56e5d0f718223f2b195181f57b6.tar.gz
reply-8df94620704fd56e5d0f718223f2b195181f57b6.zip
nopaste plugin
-rw-r--r--dist.ini2
-rw-r--r--lib/Reply/Plugin/Nopaste.pm76
2 files changed, 78 insertions, 0 deletions
diff --git a/dist.ini b/dist.ini
index 1230162..ed1cb23 100644
--- a/dist.ini
+++ b/dist.ini
@@ -9,9 +9,11 @@ dist = Reply
repository = github
[AutoPrereqs]
+skip = ^App::Nopaste$
skip = ^Data::Dump$
skip = ^Proc::InvokeEditor$
[Prereqs / RuntimeRecommends]
+App::Nopaste = 0
Data::Dump = 0
Proc::InvokeEditor = 0
diff --git a/lib/Reply/Plugin/Nopaste.pm b/lib/Reply/Plugin/Nopaste.pm
new file mode 100644
index 0000000..fdcead9
--- /dev/null
+++ b/lib/Reply/Plugin/Nopaste.pm
@@ -0,0 +1,76 @@
+package Reply::Plugin::Nopaste;
+use strict;
+use warnings;
+
+use base 'Reply::Plugin';
+
+use App::Nopaste;
+
+# XXX note that this has to be loaded early, in order to catch all of the
+# appropriate manipulations that plugins do ([DataDump], etc)
+
+sub new {
+ my $class = shift;
+
+ my $self = $class->SUPER::new(@_);
+ $self->{history} = '';
+
+ return $self;
+}
+
+sub prompt {
+ my $self = shift;
+ my ($next, @args) = @_;
+ my $prompt = $next->(@args);
+ $self->{prompt} = $prompt;
+ return $prompt;
+}
+
+sub read_line {
+ my $self = shift;
+ my ($next, @args) = @_;
+ my $line = $next->(@args);
+ $self->{line} = "$line\n" if defined $line;
+ return $line;
+}
+
+sub print_error {
+ my $self = shift;
+ my ($next, $error) = @_;
+ $self->{result} = $error;
+ $next->($error);
+}
+
+sub print_result {
+ my $self = shift;
+ my ($next, @result) = @_;
+ $self->{result} = join('', @result) . "\n";
+ $next->(@result);
+}
+
+sub loop {
+ my $self = shift;
+
+ my $prompt = delete $self->{prompt};
+ my $line = delete $self->{line};
+ my $result = delete $self->{result};
+
+ $self->{history} .= "$prompt$line$result";
+}
+
+sub command_nopaste {
+ my $self = shift;
+ my ($line) = @_;
+
+ $line = "Reply session" unless length $line;
+
+ App::Nopaste->nopaste(
+ text => $self->{history},
+ desc => $line,
+ lang => 'perl',
+ );
+
+ return '';
+}
+
+1;