#!/usr/bin/python

import argparse
# Custom shite.
from blog import say, Archive

""" Remove a post.
    Should probably reset the index afterwards.
"""


parser = argparse.ArgumentParser(description='Remove a blog post from the blog.')
parser.add_argument('post', help='blog post title or id')
args = parser.parse_args()

arch = Archive()
post = args.post
remove = None

if post.isdigit():
    post = int(post)
    remove = arch.remove
else:
    remove = arch.removeTitle

if remove(post):
    say('Removed blog post')
    arch.publish()
    post = arch.get()
    say('Front page changed to post "' + post['title'] + '"!')
else:
    say('Failed. No such post?')


