Skip to content

Commit

Permalink
Handle --help in click decorated functions
Browse files Browse the repository at this point in the history
Fixes #234

(cherry picked from commit 7976574c27bc6c9c2baa1510ebe479814cc3b3f9)
  • Loading branch information
unode committed Aug 26, 2022
1 parent f48a36e commit f6d8b98
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mmpy_bot/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ def __call__(self, message: Message, *args):
return self.function.invoke(ctx)
# If there are any missing arguments or the function is otherwise called
# incorrectly, send the click message back to the user and print help string.
except click.exceptions.ClickException as e:
except (click.exceptions.ClickException, click.exceptions.Exit) as e:
if isinstance(e, click.exceptions.Exit):
e = "Requested `--help`:"

return self.plugin.driver.reply_to(message, f"{e}\n{self.docstring}")

return self.function(self.plugin, message, *args)
Expand Down

0 comments on commit f6d8b98

Please sign in to comment.