From 556ad7a4683b437ed35e2314db01e3928ba58022 Mon Sep 17 00:00:00 2001 From: pancakes Date: Mon, 25 Nov 2024 00:07:33 +1000 Subject: [PATCH] Add CLI options --- main.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index f92a9c4..5680d55 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,7 @@ import feedparser import json from markdownify import markdownify import re +import sys import time @@ -28,7 +29,14 @@ def split_notes(text: str, limit: int) -> list[str]: if __name__ == "__main__": - config_file = open("./config.json", "r") + if len(sys.argv) < 3: + print("Usage:", sys.argv[0], " ") + exit(1) + + account = sys.argv[1] + config_path = sys.argv[2] + + config_file = open(config_path, "r") config = json.load(config_file) config_file.close() @@ -55,6 +63,6 @@ if __name__ == "__main__": config[url] = time.mktime(rss.entries[-1].published_parsed) print("Saving config", config) - config_file = open("./config.json", "w") + config_file = open(config_path, "w") json.dump(config, config_file, indent=4) config_file.close()