forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitlab-todos.template.py
executable file
·47 lines (37 loc) · 1.31 KB
/
gitlab-todos.template.py
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
42
43
44
45
46
47
#!/usr/bin/env python3
# How to use this script?
# It's a template which needs further setup. Duplicate the file,
# remove `.template.` from the filename and set an Personal access token as
# well as the GitLab instance url if it is not gitlab.com in gitlabconfig.py
# You need to copy gitlabconfig.py and gitlabhelper.py next to the script command
# otherwise it won't work. gitlabconfig.py and gitlabhelper.py are shared between
# all gitlab script commands.
#
# API: https://docs.gitlab.com/ee/api
# Parameters
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title To-Dos
# @raycast.mode fullOutput
# Optional parameters:
# @raycast.packageName GitLab
# @raycast.icon images/gitlab.png
# Documentation:
# @raycast.author Michael Aigner
# @raycast.authorURL https://github.com/tonka3000
# @raycast.description Show todos from GitLab
# Configuration
# see gitlabconfig.py
# Main program
from gitlabhelper import GitLab
gitlab = GitLab()
data = gitlab.get_call("todos")
print(f"GitLab To-Do List on {gitlab.instance}:\n")
todo_count = len(data)
print(f"To Do {todo_count}")
for todo in data:
project_name = todo.get("project", {}).get("name_with_namespace")
title = todo.get("target", {}).get("title")
web_url = todo.get("target", {}).get("web_url")
print(f"* {title} at {project_name}")
print(f"{web_url}\n")