{"action":"created","issue":{"url":"https://api.github.com/repos/pallets/click/issues/533","repository_url":"https://api.github.com/repos/pallets/click","labels_url":"https://api.github.com/repos/pallets/click/issues/533/labels{/name}","comments_url":"https://api.github.com/repos/pallets/click/issues/533/comments","events_url":"https://api.github.com/repos/pallets/click/issues/533/events","html_url":"https://github.com/pallets/click/pull/533","id":139685181,"number":533,"title":"Non standalone exit","user":{"login":"llllllllll","id":3064397,"avatar_url":"https://avatars.githubusercontent.com/u/3064397?v=3","gravatar_id":"","url":"https://api.github.com/users/llllllllll","html_url":"https://github.com/llllllllll","followers_url":"https://api.github.com/users/llllllllll/followers","following_url":"https://api.github.com/users/llllllllll/following{/other_user}","gists_url":"https://api.github.com/users/llllllllll/gists{/gist_id}","starred_url":"https://api.github.com/users/llllllllll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/llllllllll/subscriptions","organizations_url":"https://api.github.com/users/llllllllll/orgs","repos_url":"https://api.github.com/users/llllllllll/repos","events_url":"https://api.github.com/users/llllllllll/events{/privacy}","received_events_url":"https://api.github.com/users/llllllllll/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-09T20:03:16Z","updated_at":"2016-06-23T06:09:34Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pallets/click/pulls/533","html_url":"https://github.com/pallets/click/pull/533","diff_url":"https://github.com/pallets/click/pull/533.diff","patch_url":"https://github.com/pallets/click/pull/533.patch"},"body":"I am using `Command.main` with `standalone=False` and found that `--help` would still call `ctx.exit()` which turned into a call to `sys.exit()`. This change makes `Context.exit` raise a custom click exception that is handled in `Command.main`. This allows us to check if we are in standalone mode and delegate to the proper behavior. In standalone mode we just pass the exit_code from the exception to `sys.exit` like before; however, when not in standalone mode we re-raise the exception when `exit_code != 0`, otherwise we just return None. This makes it possible for commands to early exit with `ctx.exit` without breaking non standalone usage."},"comment":{"url":"https://api.github.com/repos/pallets/click/issues/comments/227958782","html_url":"https://github.com/pallets/click/pull/533#issuecomment-227958782","issue_url":"https://api.github.com/repos/pallets/click/issues/533","id":227958782,"user":{"login":"llllllllll","id":3064397,"avatar_url":"https://avatars.githubusercontent.com/u/3064397?v=3","gravatar_id":"","url":"https://api.github.com/users/llllllllll","html_url":"https://github.com/llllllllll","followers_url":"https://api.github.com/users/llllllllll/followers","following_url":"https://api.github.com/users/llllllllll/following{/other_user}","gists_url":"https://api.github.com/users/llllllllll/gists{/gist_id}","starred_url":"https://api.github.com/users/llllllllll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/llllllllll/subscriptions","organizations_url":"https://api.github.com/users/llllllllll/orgs","repos_url":"https://api.github.com/users/llllllllll/repos","events_url":"https://api.github.com/users/llllllllll/events{/privacy}","received_events_url":"https://api.github.com/users/llllllllll/received_events","type":"User","site_admin":false},"created_at":"2016-06-23T06:09:34Z","updated_at":"2016-06-23T06:09:34Z","body":"ping"}}
{"actor":{"display_login":"llllllllll"}}