#!/usr/bin/env python3
import sys

from alfred_utils import print_out
from hook_cache import HookCache

# Initialize cache
cache = HookCache()


def main():
    if len(sys.argv) < 2:
        print_out(
            title="No hook ID provided",
            subtitle="Please provide a hook ID to remove from cache",
            valid=False,
        )
        return

    hook_id = sys.argv[1].strip()
    cache_key = f"hook_{hook_id}"

    if cache.remove(cache_key):
        print_out(
            title="Cache Cleared",
            subtitle=f"Removed hook {hook_id} from cache",
            valid=False,
        )
    else:
        print_out(
            title="Not in Cache",
            subtitle=f"Hook {hook_id} was not in cache",
            valid=False,
        )


if __name__ == "__main__":
    main()
