16 print STDERR
"$Odin::PROG: $m\n";
23 while (read STDIN
, my $buf, 8192) { $c .= $buf; }
24 return Odin
::tidy_pastebin_content decode locale
=> $c;
27 my $op = shift(@ARGV) // "help";
37 new [-l LANG] [-t TITLE]
39 update [-c] [-l LANG] [-t TITLE] TAG
41 } elsif ($op eq "list") {
42 @ARGV == 0 or Odin
::fail
"usage: list";
43 my $db = Odin
::open_db
;
44 for my $r (@
{$db->selectall_arrayref
45 ("SELECT tag, stamp, lang, title
46 FROM odin_pastebin WHERE owner = ?
47 ORDER BY stamp", undef, $Odin::WHO
)}) {
48 my ($tag, $stamp, $lang, $title) = @
$r;
49 my $t = strftime
"%Y-%m-%d %H:%M:%S %z", localtime $stamp;
50 printf "%-25s %-12s %-16s %s\n",
51 $t, $tag, $lang, encode locale
=> $title;
53 } elsif ($op eq "new") {
54 my $op = Odin
::OptParse
->new(@ARGV);
55 my $p = (title
=> undef, lang
=> "txt");
56 while (my $o = $op->get) {
57 if ($o eq "l") { $p{lang
} = $op->arg; }
58 elsif ($o eq "t") { $p{title
} = decode locale
=> $op->arg; }
63 $op->ok or Odin
::fail
"usage: new [-l LANG] [-t TITLE]";
64 $p{content
} = read_content
;
65 my $db = Odin
::open_db
;
67 while (read STDIN
, my $buf, 8192) { $c .= $buf; }
68 $p{content
} = read_content
;
69 @
{$db->selectall_arrayref
70 ("SELECT lang FROM odin_pastebin_lang WHERE lang = ?", undef, $p{lang
})}
71 or Odin
::fail
"unknown language `$p{lang}'";
72 my ($tag, $edit) = Odin
::new_pastebin
%p;
73 print "$Odin::PASTEBIN/$url $edit\n";
74 } elsif ($op eq "get") {
75 @ARGV == 1 or Odin
::fail
"usage: get TAG";
77 Odin
::get_pastebin Odin
::open_db
, $tag, my %p;
78 print encode locale
=> $p{content
};
79 } elsif ($op eq "claim") {
80 @ARGV == 2 or Odin
::fail
"usage: claim TAG EDITKEY";
81 my ($tag, $key) = @ARGV;
82 Odin
::claim_pastebin
$tag, $key;
83 } elsif ($op eq "rekey") {
84 @ARGV == 1 or Odin
::fail
"usage: rekey TAG";
86 my $key = Odin
::rekey_pastebin
$tag;
88 } elsif ($op eq "del") {
89 @ARGV or Odin
::fail
"usage: del TAG ...";
90 Odin
::delete_pastebin
map { $_, undef } @ARGV;
91 } elsif ($op eq "update") {
92 my $op = Odin
::OptParse
->new(@ARGV);
95 while (my $o = $op->get) {
96 if ($o eq "c") { $contentp = 1; }
97 elsif ($o eq "l") { $p{lang
} = $op->arg; }
98 elsif ($o eq "t") { $p{title
} = decode locale
=> $op->arg; }
103 $op->ok or Odin
::fail
"usage: new [-l LANG] [-t TITLE]";
104 $p{content
} = read_content
if $contentp;
105 Odin
::update_pastebin
$tag, undef, %p or Odin
::fail
"nothing changed";
107 Odin
::fail
"unknown operation `$op'";