def exit_with_mapped_status(http_status):
"""
Given an HTTP Status, exit with either an error status of 1 or the
status mapped by what we were given.
"""
# get the mapping by looking up the state and getting the mapping attr
mapping = (click.get_current_context().ensure_object(CommandState)
.http_status_map)
# if there is a mapped exit code, exit with that. Otherwise, exit 1
if http_status in mapping:
sys.exit(mapping[http_status])
else:
sys.exit(1)
评论列表
文章目录