diff options
author | Jesse Luehrs <doy@tozt.net> | 2018-11-03 17:13:34 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2018-11-03 17:13:34 -0400 |
commit | 264e9f7fd00c81bcbb963e715a8f5c5365872c3c (patch) | |
tree | 3ea79b7ad708d6a01a2e9fb42f3748c208cd51ef /bin/nopaste | |
parent | 6702d87300b54f3aec5a2d3bc81e13b0bb801d6b (diff) | |
download | conf-264e9f7fd00c81bcbb963e715a8f5c5365872c3c.tar.gz conf-264e9f7fd00c81bcbb963e715a8f5c5365872c3c.zip |
stop using app::nopaste
Diffstat (limited to 'bin/nopaste')
-rwxr-xr-x | bin/nopaste | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/bin/nopaste b/bin/nopaste new file mode 100755 index 0000000..573af2e --- /dev/null +++ b/bin/nopaste @@ -0,0 +1,37 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.020; + +use Carp; +use File::Spec; +use File::Temp; +use POSIX 'strftime'; + +if (@ARGV > 1) { + croak "can only nopaste one file at a time"; +} + +my $date = strftime("%Y-%m-%d", localtime); +my $template = "${date}-XXXXXXXX"; +my $suffix = @ARGV + ? "-${\(File::Spec->splitdir($ARGV[0]))[-1]}" + : undef; + +my $contents = do { local $/; <> }; + +my $tmpfile = File::Temp->new( + TEMPLATE => $template, + SUFFIX => $suffix, + UNLINK => 1, + TMPDIR => 1, +); +my $tmpfilename = $tmpfile->filename; + +print $tmpfile $contents or croak "Can't write to $tmpfilename: $!"; +close $tmpfile or croak "Can't write to $tmpfilename: $!"; +chmod 0644 => $tmpfilename; + +system('scp', '-pq', $tmpfilename, "tozt.net:paste"); + +say "https://paste.tozt.net/${\(File::Spec->splitdir($tmpfilename))[-1]}"; |