Initial skill structure: Tududi task management
This commit is contained in:
87
scripts/tududi-api.sh
Executable file
87
scripts/tududi-api.sh
Executable file
@@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
# Tududi API wrapper
|
||||
# Usage: tududi-api.sh <command> [args...]
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
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
|
||||
|
||||
# Helper: make API call
|
||||
call_api() {
|
||||
local method=$1
|
||||
local endpoint=$2
|
||||
local data=${3:-}
|
||||
|
||||
if [ -z "$data" ]; then
|
||||
curl -s -X "$method" \
|
||||
-H "Authorization: Bearer $API_KEY" \
|
||||
"$API_URL$endpoint"
|
||||
else
|
||||
curl -s -X "$method" \
|
||||
-H "Authorization: Bearer $API_KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$data" \
|
||||
"$API_URL$endpoint"
|
||||
fi
|
||||
}
|
||||
|
||||
# Commands
|
||||
case "${1:-help}" in
|
||||
add-task)
|
||||
# Usage: tududi-api.sh add-task "name" "description" "project_id"
|
||||
name="${2:-}"
|
||||
desc="${3:-}"
|
||||
project_id="${4:-}"
|
||||
|
||||
if [ -z "$name" ]; then
|
||||
echo "Usage: tududi-api.sh add-task <name> [description] [project_id]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
payload="{\"name\":\"$name\""
|
||||
[ -n "$desc" ] && payload="${payload},\"note\":\"$desc\""
|
||||
[ -n "$project_id" ] && payload="${payload},\"project_id\":$project_id"
|
||||
payload="${payload}}"
|
||||
|
||||
call_api POST "/tasks" "$payload" | jq .
|
||||
;;
|
||||
|
||||
list-inbox)
|
||||
# Get tasks with no project (inbox)
|
||||
call_api GET "/tasks?project_id=null" | jq '.tasks[] | {id, name, due_date, priority}' | head -20
|
||||
;;
|
||||
|
||||
list-projects)
|
||||
# Get all projects
|
||||
call_api GET "/projects" | jq '.[] | {id, name, status}' | head -20
|
||||
;;
|
||||
|
||||
get-task)
|
||||
# Get single task details
|
||||
task_id="${2:-}"
|
||||
if [ -z "$task_id" ]; then
|
||||
echo "Usage: tududi-api.sh get-task <task_id>" >&2
|
||||
exit 1
|
||||
fi
|
||||
call_api GET "/tasks/$task_id" | jq .
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Tududi API wrapper"
|
||||
echo ""
|
||||
echo "Commands:"
|
||||
echo " add-task <name> [description] [project_id]"
|
||||
echo " list-inbox"
|
||||
echo " list-projects"
|
||||
echo " get-task <task_id>"
|
||||
echo ""
|
||||
echo "Set TUDUDI_API_URL and TUDUDI_API_KEY env vars"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user