grimoire-ssg/grimoiressg/arguments.py

33 lines
1.1 KiB
Python
Raw Normal View History

import argparse
2025-01-10 17:53:57 +00:00
from grimoiressg.utils import logger
def parse_arguments_to_initial_context():
parser = argparse.ArgumentParser(
description='''
Grimoire is a minimalistic Static Site Generator.
In the simplest case the only argument needed is at least one content file. \
The rest of the flags is used to customize the behavior.
'''
)
parser.add_argument("content_file", nargs="+", help="one or more content files")
parser.add_argument("-o", "--output", default="./output/", help="the output directory (default: ./output/)")
parser.add_argument("-c", "--config", help="the config file to use")
args, _ = parser.parse_known_args()
context = {
"output_dir": args.output,
"config_file": args.config,
"filenames": args.content_file
}
2025-01-10 17:53:57 +00:00
logger.debug("Output directory: %s", context['output_dir'])
logger.debug("Config file: %s", context['config_file'])
logger.debug("Content files:")
for filename in context["filenames"]:
2025-01-10 17:53:57 +00:00
logger.debug(" - %s", filename)
return context