Add CLI options

This commit is contained in:
pancakes 2024-11-25 00:07:33 +10:00
parent cdfd3619f0
commit 556ad7a468
No known key found for this signature in database
GPG key ID: ED53D426432B861B

12
main.py
View file

@ -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], "<account> <config>")
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()