from typing import Callable
import click


def max_num_results_option(
    command: Callable[..., None],
) -> Callable[..., None]:
    """
    An option decorator for choosing the maximum number of query results.
    """
    maximum = 50
    click_option_function = click.option(
        '--max-num-results',
        type=click.IntRange(min=1, max=maximum),
        default=1,
        help=(
            'The maximum number of matching targets to be returned. '
            f'Must be <= {maximum}.'
        ),
        show_default=True,
    )

    return click_option_function(command)