From 5d9d0dfa35fcca2f409aee8e1d406e0097e787e0 Mon Sep 17 00:00:00 2001 From: Jean-Louis Fuchs Date: Tue, 21 May 2024 14:38:23 +0200 Subject: [PATCH] fix: show stack traces in debug mode --- pyaptly/cli.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pyaptly/cli.py b/pyaptly/cli.py index 0c5c8d5..5ea28c1 100644 --- a/pyaptly/cli.py +++ b/pyaptly/cli.py @@ -19,12 +19,18 @@ def entry_point(): if len_argv > 0 and argv[0].endswith("pyaptly"): if len_argv > 2 and argv[1] == "legacy" and argv[2] != "--": argv = argv[:2] + ["--"] + argv[2:] + if "--debug" in argv or "-d" in argv: + debug = True + else: + debug = False try: cli.main(argv[1:]) except CalledProcessError: pass # already logged except Exception as e: + if debug: + raise from . import util path = util.write_traceback() @@ -160,6 +166,7 @@ def publish(**kwargs): @cli.command(help="convert yaml- to toml-comfig") +@click.option("--debug/--no-debug", "-d/-nd", default=False, type=bool) @click.argument( "yaml_path", type=click.Path( @@ -187,7 +194,7 @@ def publish(**kwargs): default=False, help="Add default values to fields if missing", ) -def yaml_to_toml(yaml_path: Path, toml_path: Path, add_defaults: bool): +def yaml_to_toml(yaml_path: Path, toml_path: Path, add_defaults: bool, debug: bool): """Convert pyaptly config files from yaml to toml.""" from . import config_file