#!/usr/bin/env bash
#
# Enable 1Password CLI biometric unlock for bugwarrior
#

set -euo pipefail

echo "🔐 Setting up 1Password CLI biometric unlock..."
echo ""
echo "This will enable Touch ID for 1Password CLI, reducing password prompts."
echo ""

# Enable biometric unlock
op account add --address my.1password.com --shorthand personal
op account add --address nf-core.1password.eu --shorthand work

echo ""
echo "✅ Biometric unlock enabled!"
echo ""
echo "Now let's update your bugwarrior config to use biometric auth..."

# Create a wrapper that uses biometric auth
cat > ~/.local/bin/op-biometric << 'EOF'
#!/usr/bin/env bash
# Wrapper for op that ensures biometric auth is used
export OP_BIOMETRIC_UNLOCK_ENABLED=true
exec /opt/homebrew/bin/op "$@"
EOF

chmod +x ~/.local/bin/op-biometric

echo "✅ Created biometric wrapper"
echo ""
echo "Next steps:"
echo "1. Update your bugwarrior config to use the wrapper:"
echo "   Change: @oracle:eval:op read ..."
echo "   To:     @oracle:eval:op-biometric read ..."
echo ""
echo "2. Or use a service account token for completely headless operation:"
echo "   https://developer.1password.com/docs/service-accounts/"