38 lines
860 B
Bash
Executable File
38 lines
860 B
Bash
Executable File
#!/bin/bash
|
|
# Quick add task from "todo [name]" pattern
|
|
# Usage: quick-add.sh "Configure Tailscale VPN"
|
|
|
|
set -euo pipefail
|
|
|
|
task_name="${1:-}"
|
|
|
|
if [ -z "$task_name" ]; then
|
|
echo "Usage: quick-add.sh <task_name>" >&2
|
|
exit 1
|
|
fi
|
|
|
|
API_URL="${TUDUDI_API_URL:-https://todo.dilain.com/api/v1}"
|
|
API_KEY="${TUDUDI_API_KEY}"
|
|
|
|
if [ -z "$API_KEY" ]; then
|
|
echo "Error: TUDUDI_API_KEY not set" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Add to inbox via POST /api/v1/inbox (preferred for quick capture)
|
|
response=$(curl -s -X POST \
|
|
-H "Authorization: Bearer $API_KEY" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"content\":\"$task_name\"}" \
|
|
"$API_URL/inbox")
|
|
|
|
task_uid=$(echo "$response" | jq -r '.uid // empty')
|
|
|
|
if [ -n "$task_uid" ]; then
|
|
echo "✅ Added to Tududi: $task_name (uid: $task_uid)"
|
|
else
|
|
echo "⚠️ Failed to add task"
|
|
echo "Response: $response"
|
|
exit 1
|
|
fi
|