import sys
import secrets

def generate_api_key():
    return secrets.token_hex(16)

def main():
    key = generate_api_key()
    if len(sys.argv) > 1:
        path = sys.argv[1]
        with open(path, "w") as f:
            f.write(key + "\n")
        print(key)
    else:
        print(key)
