def main(self, signature=''):
        """
        A decorator that is used to register the main function with the given
        `signature`::

            @app.main()
            def main(context):
                # do something
                pass

        The main function is called, after any options and if no command has
        been called.
        """
        signature = Signature.from_string(signature, option=False)

        def decorator(function):
            if self.main_func is not None:
                raise RuntimeError('main is already defined')
            try:
                function = annotations()(function)
            except RuntimeError:
                pass

            self.main_func = function
            self.main_signature = signature
            if function.__doc__:
                self.description = textwrap.dedent(function.__doc__).strip()
            return function
        return decorator