-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
59 lines (50 loc) · 1.18 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
package main
import (
"fmt"
"os"
"strings"
"time"
aw "github.com/deanishe/awgo"
"github.com/deanishe/awgo/update"
)
var (
// icons
updateAvailable = &aw.Icon{Value: "icons/update-available.png"}
cacheName = "repos.json"
maxCacheAge = 180 * time.Minute
repo = "mjhuber/alfred-jira"
query string
// aw.Workflow is the main API
wf *aw.Workflow
)
// Options contains options for connecting to the gitlab API
type Options struct {
BaseURL string `env:"JIRA_URL"`
Token string `env:"JIRA_TOKEN"`
Username string `env:"JIRA_USERNAME"`
Projects string `env:"JIRA_PROJECTS"`
}
func init() {
wf = aw.New(update.GitHub(repo), aw.HelpURL(repo+"/issues"))
}
func main() {
wf.Run(run)
}
func run() {
showUpdateStatus()
opts := &Options{}
cfg := aw.NewConfig()
if err := cfg.To(opts); err != nil {
wf.Fatalf("Error loading variables: %v", err)
return
}
switch os.Args[1] {
case "search":
queryStr := generateSearchQuery(opts, strings.Join(os.Args[2:], " "))
search(opts, queryStr)
case "search-by-key":
search(opts, fmt.Sprintf("key = %s", strings.Join(os.Args[2:], " ")))
default:
wf.Fatalf("No steps for command %s", os.Args[1])
}
}