import click

from geo.core import inspector
from geo import output


@click.command()
@click.argument("file", type=click.Path(exists=True))
@click.option("--layer", default=None, help="Layer name (for multi-layer formats)")
@click.pass_context
def info(ctx, file, layer):
    """Inspect dataset metadata: CRS, geometry type, extent, feature count, fields."""
    dataset_info = inspector.inspect(file, layer=layer)
    if ctx.obj.get("json"):
        click.echo(output.format_info_json(dataset_info))
    else:
        click.echo(output.format_info_human(dataset_info))
