#!/usr/bin/env python3
import os
import sys

_BASE_DIR = os.path.abspath(os.path.join(__file__, '..', '..'))
DRAFTS_DIR = os.path.join(_BASE_DIR, '_drafts')
POSTS_DIR = os.path.join(_BASE_DIR, '_posts')


def draft(repl_chars=['.'], del_chars=[',']):
    name_list = sys.argv[1:]
    slugged = '-'.join(map(lambda x: x.lower(), name_list))
    for char in del_chars:
        slugged = slugged.replace(char, '')
    for char in repl_chars:
        slugged = slugged.replace(char, '-')
    with open(os.path.join(DRAFTS_DIR, slugged + '.md'), 'w') as f:
        f.write('---\n')
        f.write('layout: post\n')
        f.write('title: ' + ' '.join(map(lambda x: x.capitalize(), name_list))
                + '\n')
        f.write('description:\n')
        f.write('category:\n')
        f.write('tags:\n')
        f.write('banner:\n')
        f.write('---\n')


if __name__ == '__main__':
    draft()
