diff --git a/main.py b/main.py index 537ad76..b3b9440 100644 --- a/main.py +++ b/main.py @@ -1,18 +1,24 @@ +from argparse import ArgumentParser from datetime import datetime from locale import LC_ALL, setlocale from os import makedirs, path from pathlib import Path from typing import Any +from docx2pdf import convert from docxtpl import DocxTemplate +parser = ArgumentParser(description="Ping script") +parser.add_argument( + "--convert", + dest="convert_output", + action="store_true", + help="convert output .docx files to .pdf", +) + from modules.utils import data_read, json_read -def local_if_available(data: dict, data_local: dict, *args: str) -> Any: - return - - def main(): for lang in config["languages"]: # data = json_read(Path("data", "default.json")) @@ -151,6 +157,7 @@ def main(): if __name__ == "__main__": + args = parser.parse_args() config = json_read(Path("config.json")) makedirs(Path(".cache"), exist_ok=True) if not path.exists(Path(".cache", "location")): @@ -167,3 +174,9 @@ if __name__ == "__main__": cached_location if signature_location == "" else signature_location ) main() + if args.convert_output: + print( + f"Converting everything to PDF...", + flush=True, + ) + convert(Path("output").absolute()) diff --git a/requirements.txt b/requirements.txt index 15dbf20..8864bac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ +argparse==1.4.0 +docx2pdf==0.1.8 docxtpl==0.16.6 \ No newline at end of file