# $Id$
# -*- perl -*- vim: ft=perl sw=4 sts=4
+# For documentation, run perldoc blogcl
+
use strict;
use Net::MovableType;
use Getopt::Long;
die "Invalid arguments\n" unless
GetOptions (\%opts, 'username|l=s', 'password|p=s', 'url|u=s', 'blogid|b=i', 'title|t=s', 'category|c=s', 'file|f=s');
-if ($ARGV[0] eq "help") {
- Getopt::Long::HelpMessage();
- exit(0);
-}
-
sub init_mt {
- die "No url given.\n" unless(defined("$url"));
- die "No username given.\n" unless(defined("$username"));
- die "No passowrd given.\n" unless(defined("$password"));
+ die "No url given.\n" unless(defined($opts{url}));
+ die "No username given.\n" unless(defined($opts{username}));
+ die "No passowrd given.\n" unless(defined($opts{password}));
$mt = new Net::MovableType($opts{'url'}) || die "$!";
$mt->username($opts{'username'});
$mt->password($opts{'password'});
print join("\n",map {$_->{categoryName}} @{$mt->getCategoryList()}), "\n";
}
+sub delete_post {
+ my $postid=shift;
+ my $post = $mt->getPost($postid) or die "$!";
+ my $categories = $mt->getPostCategories($postid) or die "$!";
+ if(defined($opts{file})) {
+ if($opts{file} eq "-") {
+ print STDOUT $post->{description}, "\n";
+ } else {
+ open FH, ">".$opts{file} or die "$!";
+ print $opts{file}, "\n";
+ print FH $post->{description}, "\n";
+ close FH;
+ }
+ }
+ $mt->deletePost($postid,1);
+}
+
sub show_post {
my $postid=shift;
my $post = $mt->getPost($postid) or die "$!";
} elsif ($ARGV[0] eq "show" && $ARGV[1] =~ /^\d+$/) {
init_mt();
show_post($ARGV[1])
+} elsif ($ARGV[0] eq "delete" && $ARGV[1] =~ /^\d+$/) {
+ init_mt();
+ delete_post($ARGV[1])
} else {
Getopt::Long::HelpMessage();
exit(1);
=head1 SYNOPSIS
-B<blogcl> S<[ B<--title>|B<-t> "Title" ]> S<[ B<--category>|B<-c> category[,...] ]> S<[ B<--file>|B<-f> F<file> ]> S<[ B<--username>|B<-l> username ]> S<[ B<--password>|B<-p> password ]> S<[ B<--url>|B<-u> url ]> S<[ B<--blogid>|B<-b> blogid ]> { B<new> | B<edit> postid | B<show> postid | B<list> [count] | B<categories> }
+B<blogcl> S<[ B<--title>|B<-t> "Title" ]> S<[ B<--category>|B<-c> category[,...] ]> S<[ B<--file>|B<-f> F<file> ]> S<[ B<--username>|B<-l> username ]> S<[ B<--password>|B<-p> password ]> S<[ B<--url>|B<-u> url ]> S<[ B<--blogid>|B<-b> blogid ]> { B<new> | B<edit> postid | B<show> postid | B<delete> postid | B<list> [count] | B<categories> }
=head1 DESCRIPTION
Shows the contents of the post specified by the postid given on the
command-line.
+=item B<delete>
+
+Deletes a post. Specify a B<--file> option to back up the contents (but not
+the title or category) of the post.
+
=item B<list>
List recents posts and their postids. An optional integer specifies the number
Copyright by Tim Pope. All rights reserved.
-This library is a free software; you may redistribute it and/or modify it under
+This program is a free software; you may redistribute it and/or modify it under
the same terms as perl itself.
=head1 AUTHORS