11from typing import Generator
2+ from urllib .parse import quote_plus
23
34from 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
57from github .Repository import Repository
68from 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
1822def 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