From 8433efc2c31c6d49892c8354d2f43696d322586e Mon Sep 17 00:00:00 2001 From: Starfall Date: Thu, 21 Oct 2021 20:20:36 -0500 Subject: strike: use argparser instead of hardcoding directories and filenames --- strike.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/strike.py b/strike.py index fb7378d..93c62f4 100755 --- a/strike.py +++ b/strike.py @@ -1,18 +1,25 @@ #!/usr/bin/env python3 from os import listdir, mkdir from sys import exit +import argparse def get_output(content, template="{content}"): return template.format(content = content) def main(): - src = 'blog' + parser = argparse.ArgumentParser() + parser.add_argument('--input', '-i', help='input directory (default "blog")', default='blog') + parser.add_argument('--output', '-o', help='output directory (default "output")', default='output') + parser.add_argument('--template', '-t', help='template to use (default "template"', default='template') + args = parser.parse_args() - dest = 'output' + src = args.input + + dest = args.output try: mkdir(dest) except FileExistsError: pass - template = 'template' + template = args.template with open(template) as t: template_contents = t.read() -- cgit