import click
from pathlib import Path


def _cbk_opt_inventory(ctx: click.Context, param, value):
    """callback for inventory option to read into list of strings"""
    try:
        return Path(value).read_text().splitlines()
    except Exception as exc:
        ctx.fail(f"Unable to load inventory file '{value}': {str(exc)}")