From 3f4c7c27867b0f9c6cde2da4caee92362130fc04 Mon Sep 17 00:00:00 2001 From: Benjamin Lipp Date: Tue, 16 Sep 2025 16:47:32 +0200 Subject: [PATCH] feat: add CLI param for configurable output/target directory Co-authored-by: Anja Rabich --- marzipan/TODO.md | 3 ++- marzipan/src/__init__.py | 17 +++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/marzipan/TODO.md b/marzipan/TODO.md index ee4e82d..b7f71b9 100644 --- a/marzipan/TODO.md +++ b/marzipan/TODO.md @@ -32,9 +32,10 @@ * ~~return an exit status that is meaningful for CI~~ * ~~exception handling in analyze() and in run_proverif()~~ * ~~refactor filtering in run_proverif (see karo's comment)~~ +* ~configurable target directory~ ## Next Steps -* configurable target directory + * do not assume that the repo path has subdir analysis and marzipan * integrate marzipan.awk into Python, somehow * rewrite marzipan.awk into Python/LARK diff --git a/marzipan/src/__init__.py b/marzipan/src/__init__.py index 5569b05..70401e4 100644 --- a/marzipan/src/__init__.py +++ b/marzipan/src/__init__.py @@ -158,14 +158,18 @@ def pretty_output(file_path): (res, ctr, ta) = pretty_output_step(file_path, line, expected, descs, res, ctr, ta) -def get_target_dir(path): - return pkgs.os.path.join(path, target_subdir) +def get_target_dir(path, output): + if output is not None and not output == "": + return pkgs.pathlib.Path(output) + else: + return pkgs.os.path.join(path, target_subdir) @main.command() +@click.option('--output', 'output', required=False) @click.argument("repo_path") -def analyze(repo_path): - target_dir = get_target_dir(repo_path) +def analyze(repo_path, output): + target_dir = get_target_dir(repo_path, output) pkgs.os.makedirs(target_dir, exist_ok=True) entries = [] @@ -182,10 +186,11 @@ def analyze(repo_path): @main.command() +@click.option('--output', 'output', required=False) @click.argument("repo_path") -def clean(repo_path): +def clean(repo_path, output): cleans_failed = 0 - target_dir = get_target_dir(repo_path) + target_dir = get_target_dir(repo_path, output) if pkgs.os.path.isdir(target_dir): for filename in pkgs.os.listdir(target_dir): file_path = pkgs.os.path.join(target_dir, filename)