Skip to content

Commit 774e02a

Browse files
authored
Merge pull request #24 from Garulf/dev
Dev
2 parents 9813af9 + 7da63c0 commit 774e02a

5 files changed

Lines changed: 77 additions & 5 deletions

File tree

requirements.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
pyflowlauncher==0.6.1.dev0
2-
pygithub==1.54
3-
typing-extensions==4.9.0
1+
pyflowlauncher[all]==0.7.0.dev0
2+
pygithub==1.54

src/context_menu.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from typing import Tuple
2+
3+
from pyflowlauncher.result import ResultResponse, send_results
4+
5+
from results import context_menu_results
6+
7+
8+
def context_menu(data: Tuple[str, str]) -> ResultResponse:
9+
return send_results(context_menu_results(*data))

src/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Name": "Github Quick Launcher",
55
"Description": "Quickly access your personal repositories and stars.",
66
"Author": "Garulf",
7-
"Version": "3.0.1",
7+
"Version": "3.1.0",
88
"Language": "python",
99
"Website": "https://github.com/Garulf/github-quick-launcher",
1010
"IcoPath": "./icon.png",

src/plugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
from pyflowlauncher import Plugin
44
from query import query
5+
from context_menu import context_menu
56

67

78
def main(plugin: Optional[Plugin] = None):
89
plugin = plugin or Plugin()
910

1011
plugin.add_method(query)
12+
plugin.add_method(context_menu)
1113
plugin.run()

src/results.py

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from typing import Generator
2+
from urllib.parse import quote_plus
23

34
from pyflowlauncher.result import Result
4-
from pyflowlauncher.api import open_url
5+
from pyflowlauncher.api import open_url, copy_to_clipboard
6+
from pyflowlauncher.icons import BROWSER, OPEN, COPY
57
from github.Repository import Repository
68
from github.PaginatedList import PaginatedList
79

@@ -12,9 +14,69 @@ def repo_result(repo: Repository) -> Result:
1214
SubTitle=repo.description,
1315
IcoPath=repo.owner.avatar_url,
1416
JsonRPCAction=open_url(repo.html_url),
17+
CopyText=repo.full_name,
18+
ContextData=[repo.full_name, repo.html_url],
1519
)
1620

1721

1822
def repo_results(repos: PaginatedList) -> Generator[Result, None, None]:
1923
for repo in repos.get_page(0):
2024
yield repo_result(repo)
25+
26+
27+
def context_menu_results(full_name: str, html_url: str):
28+
yield Result(
29+
Title="Open in browser",
30+
SubTitle="Open repository in browser",
31+
IcoPath=BROWSER,
32+
JsonRPCAction=open_url(html_url)
33+
)
34+
yield Result(
35+
Title="Open with GitHub Desktop",
36+
SubTitle="Open repository in GitHub Desktop",
37+
IcoPath=OPEN,
38+
JsonRPCAction=open_url(
39+
f"x-github-client://openRepo/{quote_plus(full_name)}"
40+
)
41+
)
42+
yield Result(
43+
Title="Open in VS Code",
44+
SubTitle="Open repository in VS Code",
45+
IcoPath=OPEN,
46+
JsonRPCAction=open_url(
47+
f"vscode://vscode.git/clone?url={quote_plus(html_url)}"
48+
)
49+
)
50+
yield Result(
51+
Title="Copy full name",
52+
SubTitle=full_name,
53+
IcoPath=COPY,
54+
JsonRPCAction=copy_to_clipboard(full_name)
55+
)
56+
yield Result(
57+
Title="Copy URL",
58+
SubTitle=html_url,
59+
IcoPath=COPY,
60+
JsonRPCAction=copy_to_clipboard(html_url)
61+
)
62+
https_clone_url = f"{html_url}.git"
63+
yield Result(
64+
Title="Clone with HTTPS",
65+
SubTitle=https_clone_url,
66+
IcoPath=COPY,
67+
JsonRPCAction=copy_to_clipboard(https_clone_url)
68+
)
69+
ssh_clone_url = f"git@github.com:{full_name}.git"
70+
yield Result(
71+
Title="Clone with SSH",
72+
SubTitle=ssh_clone_url,
73+
IcoPath=COPY,
74+
JsonRPCAction=copy_to_clipboard(ssh_clone_url)
75+
)
76+
github_cli_url = f"gh repo clone {full_name}"
77+
yield Result(
78+
Title="Clone with GitHub CLI",
79+
SubTitle=github_cli_url,
80+
IcoPath=COPY,
81+
JsonRPCAction=copy_to_clipboard(github_cli_url)
82+
)

0 commit comments

Comments
 (0)