2026-02-09 14:07:39 +01:00
|
|
|
#!/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
|
|
|
|
|
|
2026-02-09 15:50:11 +01:00
|
|
|
# Create task via POST /api/v1/task (singular endpoint)
|
2026-02-09 14:07:39 +01:00
|
|
|
response=$(curl -s -X POST \
|
|
|
|
|
-H "Authorization: Bearer $API_KEY" \
|
|
|
|
|
-H "Content-Type: application/json" \
|
|
|
|
|
-d "{\"name\":\"$task_name\"}" \
|
2026-02-09 15:50:11 +01:00
|
|
|
"$API_URL/task")
|
2026-02-09 14:07:39 +01:00
|
|
|
|
2026-02-09 15:50:11 +01:00
|
|
|
task_uid=$(echo "$response" | jq -r '.uid // empty')
|
2026-02-09 14:07:39 +01:00
|
|
|
|
2026-02-09 15:50:11 +01:00
|
|
|
if [ -n "$task_uid" ]; then
|
|
|
|
|
echo "✅ Added to Tududi: $task_name (uid: $task_uid)"
|
2026-02-09 14:07:39 +01:00
|
|
|
else
|
|
|
|
|
echo "⚠️ Failed to add task"
|
2026-02-09 15:50:11 +01:00
|
|
|
echo "Response: $response"
|
2026-02-09 14:07:39 +01:00
|
|
|
exit 1
|
|
|
|
|
fi
|