From 1cc839feef254d554f70407a920498cedf563ad4 Mon Sep 17 00:00:00 2001 From: Abin Simon Date: Sat, 30 Mar 2024 09:48:03 +0530 Subject: [PATCH] [scripts] ,linear-tickets: list and open linear tickets --- scripts/.local/bin/random/,linear-tickets | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 scripts/.local/bin/random/,linear-tickets diff --git a/scripts/.local/bin/random/,linear-tickets b/scripts/.local/bin/random/,linear-tickets new file mode 100755 index 00000000..6d102fe6 --- /dev/null +++ b/scripts/.local/bin/random/,linear-tickets @@ -0,0 +1,29 @@ +#!/bin/sh + +# List and open linear tickets assigned to you +# https://developers.linear.app/docs +# https://studio.apollographql.com/public/Linear-API/variant/current/schema/reference + +set -e + +tmpfile="/tmp/linear-tickets" + +if [ "$(find "$tmpfile" -mmin -10 2>/dev/null)" = "" ]; then + printf "Fetching linear tickets...\r" + curl -sX POST \ + -H "Content-Type: application/json" \ + -H "Authorization: $LINEAR_TOKEN" \ + -d '{"query": "query {user(id: \"'"$LINEAR_USER_ID"'\") {id organization { urlKey } name assignedIssues {nodes {identifier state {type} title}}}}"}' \ + https://api.linear.app/graphql >"$tmpfile" +fi + +format_issues() { + jq -r '.data.user.assignedIssues.nodes[]|"[\(.state.type)] \(.identifier) \(.title)"' <"$tmpfile" +} + +urlkey="$(jq -r '.data.user.organization.urlKey' <"$tmpfile")" + +{ + format_issues | grep -E "^\[started" + format_issues | grep -E "^\[unstarted" +} | ,picker -m | cut -d' ' -f2 | xargs -I{} open "https://linear.app/$urlkey/issue/{}" \ No newline at end of file