import sys
from license_client import LicenseClient

BASE_URL = "https://YOUR-SERVER"  # your license server (https:// only)
PRODUCT = "YOUR_PRODUCT_ID"  # shown on the product's page in your dashboard
PUBLIC_KEY_B64 = "PASTE_PUBLIC_KEY_FROM_THE_DOCS"  # public - not a secret

if __name__ == "__main__":
    key = sys.argv[1] if len(sys.argv) > 1 else input("License key: ")
    client = LicenseClient(base_url=BASE_URL, product=PRODUCT, public_key_b64=PUBLIC_KEY_B64)
    result = client.check(key)

    if result.valid:
        note = " (offline grace period)" if result.from_offline_cache else ""
        print(f"License OK — status={result.status}, expires_at={result.expires_at}{note}")
    else:
        print(f"License invalid: {result.reason}")
        sys.exit(1)
