#!/bin/bash

# API Key Manager Demo Script
# Shows all the available commands

echo "🔐 API Key Manager - Quick Commands Demo"
echo "========================================"
echo ""
echo "📚 Available Tools:"
echo ""

echo "1️⃣  Interactive TUI (Beautiful Terminal Interface):"
echo "   python3 scripts/key_manager_tui.py"
echo ""

echo "2️⃣  Simple CLI Commands:"
echo "   # Consolidate all keys from projects"
echo "   python3 scripts/simple_key_manager.py consolidate"
echo ""
echo "   # Export to .env file"
echo "   python3 scripts/simple_key_manager.py export output.env"
echo ""
echo "   # Export only AI keys"
echo "   python3 scripts/simple_key_manager.py export ai_keys.env --category=ai"
echo ""
echo "   # Show report"
echo "   python3 scripts/simple_key_manager.py report"
echo ""

echo "3️⃣  Secure Vault (when cryptography is working):"
echo "   # Add a key"
echo "   python3 scripts/key_vault.py add OPENAI_API_KEY --category=ai"
echo ""
echo "   # List all keys"
echo "   python3 scripts/key_vault.py list"
echo ""
echo "   # Export to .env"
echo "   python3 scripts/key_vault.py export .env --project=trax"
echo ""
echo "   # Validate project requirements"
echo "   python3 scripts/key_vault.py validate trax"
echo ""

echo "4️⃣  Migration Tool:"
echo "   # Scan and migrate all keys"
echo "   python3 scripts/migrate_keys.py"
echo ""
echo "   # Automatic migration"
echo "   python3 scripts/migrate_keys.py --auto --conflict-resolution=newest"
echo ""

echo "📁 Key Storage Locations:"
echo "   • Consolidated Keys: /Users/enias/projects/my-ai-projects/config/consolidated_keys.json"
echo "   • Exported .env: scripts/consolidated.env"
echo ""

echo "🚀 Quick Start:"
echo "   1. Run the TUI: python3 scripts/key_manager_tui.py"
echo "   2. Press '5' to scan all projects"
echo "   3. Press '7' to view statistics"
echo "   4. Press '6' to export keys"
echo ""

echo "📊 Current Status:"
python3 -c "
import json
from pathlib import Path

keys_file = Path('/Users/enias/projects/my-ai-projects/config/consolidated_keys.json')
if keys_file.exists():
    with open(keys_file, 'r') as f:
        data = json.load(f)
    print(f'   • Total Keys: {data.get(\"total_keys\", 0)}')
    if 'keys' in data:
        for cat, keys in data['keys'].items():
            print(f'   • {cat.capitalize()}: {len(keys)} keys')
else:
    print('   • No keys consolidated yet')
"