-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinear
More file actions
executable file
·43 lines (31 loc) · 1.05 KB
/
linear
File metadata and controls
executable file
·43 lines (31 loc) · 1.05 KB
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
#!/usr/bin/env python
import re
import os
# ~/dev/new-machine/zshrc/local-overrides
WS = os.environ["LINEAR_WORKSPACE"]
TEAM = os.environ["LINEAR_TEAM"]
def url(*fragments):
return f"https://linear.app/{WS}" + "/".join(fragments)
def search(terms: list[str]):
joined = "+".join(terms)
return f"https://linear.app/{WS}/search?q={joined}"
def details(item: str):
if re.match(r"^[0-9]+$", item):
return f"https://linear.app/{WS}/issue/{TEAM}-{item}"
elif re.match(r"^[a-z]+-[0-9]+$", item, re.IGNORECASE):
return f"https://linear.app/{WS}/issue/{item}"
return search([item])
def format_query(terms: list[str]):
match terms:
case []:
return f"https://linear.app/{WS}/team/{TEAM}/active"
case ["bl"] | ["backlog"]:
return f"https://linear.app/{WS}/team/{TEAM}/backlog"
case [item]:
return details(item)
case _:
return search(terms)
if __name__ == "__main__":
import sys
query_terms = sys.argv[1:]
print(format_query(query_terms))