forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-tasks.template.sh
executable file
·41 lines (30 loc) · 951 Bytes
/
get-tasks.template.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# Required parameters:
# @raycast.author Faris Aziz
# @raycast.authorURL https://github.com/farisaziz12
# @raycast.schemaVersion 1
# @raycast.title Get Tasks
# @raycast.mode fullOutput
# @raycast.packageName Todoist
# @raycast.description Gets All Todoist tasks
# @raycast.needsConfirmation false
# Dependency: requires jq (https://stedolan.github.io/jq/)
# Install via Homebrew: `brew install jq`
# Optional parameters:
# @raycast.icon images/todoist-logo.png
# Get your API Token from: https://todoist.com/prefs/integrations
API_TOKEN=
if ! command -v jq &> /dev/null; then
echo "jq is required (https://stedolan.github.io/jq/).";
exit 1;
fi
if [ -z "$API_TOKEN" ]; then
echo "Todoist API token is missing.";
exit 1;
fi
TASKS=$(curl -s -X GET \
https://api.todoist.com/rest/v1/tasks \
-H "Authorization: Bearer $API_TOKEN")
echo "$TASKS" | jq '.[] | .content'
echo
echo "You have $(echo "$TASKS" | jq 'length') tasks"