Execute the provided function if there are no subcommands

def run(func):
    """Execute the provided function if there are no subcommands"""

    @defaults.command(help='Run the service')
    @click.pass_context
    def runserver(ctx, *args, **kwargs):
        if (ctx.parent.invoked_subcommand and
                ctx.command.name != ctx.parent.invoked_subcommand):
            return

        # work around the fact that tornado's parse_command_line can't
        # cope with having subcommands / positional arguments.
        sys.argv = [sys.argv[0]] + [a for a in sys.argv if a[0] == '-']

        sys.exit(func())

    return runserver