initial commit
This commit is contained in:
parent
46328a92a8
commit
c449f9d9ac
12 changed files with 457 additions and 4 deletions
23
generate.py
Normal file
23
generate.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
import argparse
|
||||
from datetime import datetime
|
||||
|
||||
# Argument Parser
|
||||
argparser = argparser = argparse.ArgumentParser(description = "Generate a .md file with a pre-filled title, date, etc.")
|
||||
argparser.add_argument("output", help = "The location to generate the template to")
|
||||
argparser.add_argument("--title", help = "The title of the article (default: Blog Post)", default = "Blog Post")
|
||||
argparser.add_argument("--author", help = "The name of the author (default: Blog Author)", default = "Blog Author")
|
||||
argparser.add_argument("-v", help = "more output", action = "store_true", dest = "verbose")
|
||||
args = argparser.parse_args()
|
||||
|
||||
date = datetime.now().astimezone().strftime('%Y-%m-%dT%H:%M:%S%z')
|
||||
template = "+++\ntitle = '{}'\ndate = {}\nauthor = '{}'\ndraft = True\n+++"
|
||||
output = template.format(args.title, date, args.author)
|
||||
if args.verbose: print(template)
|
||||
|
||||
# time to write the file :3
|
||||
with open(args.output, "w+") as file:
|
||||
if args.verbose: print("Writing to {}...".format(args.output))
|
||||
file.write(output)
|
||||
print("Finished writing file to {}".format(args.output))
|
||||
|
||||
print("Done.")
|
Loading…
Add table
Add a link
Reference in a new issue