Skip to content

Ensure the correct exit code is returned when a ToolsError is raised #23

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion mbed_tools/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
"""Integration point with all sub-packages."""
import logging
import sys
from pkg_resources import working_set

from typing import Union, Any
Expand Down Expand Up @@ -32,9 +33,11 @@ def invoke(self, context: click.Context) -> None:
"""
# Use the context manager to ensure tools exceptions (expected behaviour) are shown as messages to the user,
# but all other exceptions (unexpected behaviour) are shown as errors.
with MbedToolsHandler(LOGGER, context.params["traceback"]):
with MbedToolsHandler(LOGGER, context.params["traceback"]) as handler:
super().invoke(context)

sys.exit(handler.return_code)


def print_version(context: click.Context, param: Union[click.Option, click.Parameter], value: bool) -> Any:
"""A click callback which prints the versions of all Mbed Python packages."""
Expand Down
1 change: 1 addition & 0 deletions news/20200507.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Exit with correct return code.