#!/usr/bin/env python
import sys
import click
from ap_validator.app_package import AppPackage


@click.command(
    help="Checks whether the given CWL file (URL or local file path) "
    "is compliant with the OGC application package best practices"
)
@click.option(
    "--entry-point",
    "entry_point",
    help="Name of entry point (Workflow or CommandLineTool)",
)
@click.option(
    "--detail",
    "detail",
    type=click.Choice(["none", "errors", "hints", "all"]),
    default="hints",
    help="Output detail (none|errors|hints|all; default: hints",
)
@click.option(
    "--format",
    "format",
    type=click.Choice(["text", "json"]),
    default="text",
    help="Output format (text|json; default: text)",
)
@click.argument("cwl_url")
def main(cwl_url, entry_point=None, detail="errors", format="text"):
    sys.exit(AppPackage.process_cli(cwl_url, entry_point=entry_point, detail=detail, format=format))


if __name__ == "__main__":
    main()
