def resultcallback(self, replace=False):
def decorator(f):<EOL><INDENT>old_callback = self.result_callback<EOL>if old_callback is None or replace:<EOL><INDENT>self.result_callback = f<EOL>return f<EOL><DEDENT>def function(__value, *args, **kwargs):<EOL><INDENT>return f(old_callback(__value, *args, **kwargs),<EOL>*args, **kwargs)<EOL><DEDENT>self.result_callback = rv = update_wrapper(function, f)<EOL>return rv<EOL><DEDENT>return decorator<EOL>
Adds a result callback to the chain command.  By default if a
        result callback is already registered this will chain them but
        this can be disabled with the `replace` parameter.  The result
        callback is invoked with the return value of the subcommand
        (or the list of return values from all subcommands if chaining
        is enabled) as well as the parameters as they would be passed
        to the main callback.

        Example::

            @click.group()
            @click.option('-i', '--input', default=23)
            def cli(input):
                return 42

            @cli.resultcallback()
            def process_result(result, input):
                return result + input

        .. versionadded:: 3.0

        :param replace: if set to `True` an already existing result
                        callback will be removed.