-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.go
103 lines (88 loc) · 1.99 KB
/
main.go
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package main
import (
"flag"
aw "github.com/deanishe/awgo"
"github.com/deanishe/awgo/update"
API "github.com/jopemachine/alfred-chromium-workflow/src"
"github.com/klauspost/lctime"
)
var wf *aw.Workflow
func alfredCallback() {
flag.Parse()
if args := flag.Args(); len(args) > 0 {
commandType := args[0]
var query string
if len(args) > 1 {
query = args[1]
} else {
query = ""
}
API.EnsureFaviconCacheUptodated(wf)
switch commandType {
// Fetch data
case "search-log":
API.FetchSearchData(wf, query)
case "visit-history":
API.FetchHistory(wf, query)
case "bookmark":
API.FetchBookmark(wf, query)
case "bookmark-folder":
API.FetchBookmarkFolder(wf, query)
case "download":
API.FetchDownloadHistory(wf, query, false)
case "download-show-only-existing":
API.FetchDownloadHistory(wf, query, true)
case "login":
API.FetchLoginData(wf, query)
case "autofill":
API.FetchAutofillData(wf, query)
// Tab, window related features
case "listup-tabs":
API.ListOpenedTabs(wf, query)
return
case "close-tab":
API.CloseTab(query)
return
case "focus-tab":
API.FocusTab(query)
return
case "new-window":
API.OpenNewWindow()
return
case "new-tab":
API.OpenNewTab()
return
// Change setting
case "helper":
API.RunWorkflowHelper(wf, query)
case "update-workflow":
API.UpdateWorkflow(wf)
return
case "cache-favicons":
API.CacheFavicons(wf)
return
case "select-profile":
API.SelectProfile(wf, query)
case "change-profile":
API.ChangeProfile(query)
return
case "select-browser":
API.SelectBrowser(wf, query)
case "change-browser":
API.ChangeBrowser(query)
return
}
wf.SendFeedback()
} else {
panic("Invalid argument values.")
}
}
func init() {
repoUrl := "jopemachine/alfred-chromium-workflow"
wf = aw.New(update.GitHub(repoUrl), aw.HelpURL(repoUrl+"/issues"), aw.MaxResults(200))
}
func main() {
API.ImportConfig()
lctime.SetLocale(API.Conf.Locale)
wf.Run(alfredCallback)
}