-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
resultcallback is not being called when invoke_without_command=True #1178
Comments
Click 6 will only receive security fixes. Please verify that this still happens on Click 7. |
I've confirmed this happens with click 7.0 on python 3.5.2. Here is some minimal code to reproduce the issue (test.py):
If the subcommand is invoked (i.e, |
I'm not familiar with |
I'm looking into this issue at the moment |
The documentation states that Another example in the docs shows the result callback being invoked when using subcommands which is what it is meant for. From this I think that |
@IamCathal further on in the doc for Looking through the code, the picture gets more complicated. If Lines 1261 to 1272 in 35f73b8
So it seems like this is intentional behavior, but there's no explanation for why it was done. The best explanation I can guess is that in a chain you would get an empty list for no commands, but for a regular group you'd only get I'm ok with changing this behavior. |
Going to modify this slightly in 8.1 based on #2124. If the group returns a value (and is not in chain mode), that value will be passed to the result callback, instead of ignoring it and always passing @group.result_callback
@click.pass_context
def group_result(ctx, value):
if ctx.invoked_subcommand is None:
# value was from group, not subcommand In chain mode, the group return value is ignored, which was the behavior before this change. |
I have a group-command (called
groupcmd
) which I would like the user to be able to invoke without having to specify a subcommand. I also have a resultcallback (via@groupcmd.resultcallback
) which I would like to call after the group-command finishes for processing errors and logging them to file.If I set
invoke_without_command=True
inside of the@click.group
definition, then the resultcallback does not get called.I am using click 6.6 on python 2.7.12
The text was updated successfully, but these errors were encountered: