Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show stack traces in debug mode #111

Merged
merged 1 commit into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pyaptly/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: it's of course a matter of preference but you could make this a one liner: debug = "--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()
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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

Expand Down