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 " . Odin
::sql_timestamp
($db, "stamp") .
47 FROM odin_pastebin WHERE owner = ?
48 ORDER BY stamp", undef, $Odin::WHO
)}) {
49 my ($stamp, $tag, $lang, $title) = @
$r;
50 my $t = strftime
"%Y-%m-%d %H:%M:%S %z", localtime $stamp;
51 printf "%-25s %-12s %-16s %s\n",
52 $t, $tag, $lang, encode locale
=> $title;
54 } elsif ($op eq "new") {
55 my $op = Odin
::OptParse
->new(@ARGV);
56 my $p = (title
=> undef, lang
=> "txt");
57 while (my $o = $op->get) {
58 if ($o eq "l") { $p{lang
} = $op->arg; }
59 elsif ($o eq "t") { $p{title
} = decode locale
=> $op->arg; }
64 $op->ok or Odin
::fail
"usage: new [-l LANG] [-t TITLE]";
65 $p{content
} = read_content
;
66 my $db = Odin
::open_db
;
68 while (read STDIN
, my $buf, 8192) { $c .= $buf; }
69 $p{content
} = read_content
;
70 @
{$db->selectall_arrayref
71 ("SELECT lang FROM odin_pastebin_lang WHERE lang = ?", undef, $p{lang
})}
72 or Odin
::fail
"unknown language `$p{lang}'";
73 my ($tag, $edit) = Odin
::new_pastebin
%p;
74 print "$Odin::PASTEBIN/$url $edit\n";
75 } elsif ($op eq "get") {
76 @ARGV == 1 or Odin
::fail
"usage: get TAG";
78 Odin
::get_pastebin Odin
::open_db
, $tag, my %p;
79 print encode locale
=> $p{content
};
80 } elsif ($op eq "claim") {
81 @ARGV == 2 or Odin
::fail
"usage: claim TAG EDITKEY";
82 my ($tag, $key) = @ARGV;
83 Odin
::claim_pastebin
$tag, $key;
84 } elsif ($op eq "rekey") {
85 @ARGV == 1 or Odin
::fail
"usage: rekey TAG";
87 my $key = Odin
::rekey_pastebin
$tag;
89 } elsif ($op eq "del") {
90 @ARGV or Odin
::fail
"usage: del TAG ...";
91 Odin
::delete_pastebin
map { $_, undef } @ARGV;
92 } elsif ($op eq "update") {
93 my $op = Odin
::OptParse
->new(@ARGV);
96 while (my $o = $op->get) {
97 if ($o eq "c") { $contentp = 1; }
98 elsif ($o eq "l") { $p{lang
} = $op->arg; }
99 elsif ($o eq "t") { $p{title
} = decode locale
=> $op->arg; }
104 $op->ok or Odin
::fail
"usage: new [-l LANG] [-t TITLE]";
105 $p{content
} = read_content
if $contentp;
106 Odin
::update_pastebin
$tag, undef, %p or Odin
::fail
"nothing changed";
108 Odin
::fail
"unknown operation `$op'";