From 6c8bdd53c5ba6a3a0bdbb89c8481ab194cf0a815 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Jan 12 2023 02:44:53 +0000 Subject: Add --create-directory flag to emulate distgit --- diff --git a/go2rpm/__main__.py b/go2rpm/__main__.py index eb79fad..c5121fa 100644 --- a/go2rpm/__main__.py +++ b/go2rpm/__main__.py @@ -7,6 +7,7 @@ import shutil import subprocess import sys import time +from pathlib import Path import aiohttp import asyncio @@ -574,6 +575,12 @@ def main(): parser.add_argument( "--clean-all", action="store_true", help="Clean all cached Go imports" ) + parser.add_argument( + "-d", + "--create-directory", + action="store_true", + help="Save the final specfile output to NAME/NAME.spec", + ) parser.add_argument("goipath", help="Import path") args = parser.parse_args() @@ -718,7 +725,9 @@ def main(): if licenses != "": kwargs["licenses"] = licenses - spec_file = f"{name}.spec" + output_dir = Path(name) if args.create_directory else Path(".") + output_dir.mkdir(exist_ok=True) + spec_file = output_dir / f"{name}.spec" spec_contents = template.render(**kwargs) if args.stdout: print(f"# {spec_file}") @@ -726,6 +735,7 @@ def main(): else: with open(spec_file, "w") as fobj: fobj.write(spec_contents) + print(spec_file) if __name__ == "__main__":