forked from andygrunwald/go-jira
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (35 loc) · 846 Bytes
/
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
package main
import (
"bufio"
"fmt"
"golang.org/x/term"
"os"
"strings"
"syscall"
jira "github.com/andygrunwald/go-jira"
)
func main() {
r := bufio.NewReader(os.Stdin)
fmt.Print("Jira URL: ")
jiraURL, _ := r.ReadString('\n')
fmt.Print("Jira Username: ")
username, _ := r.ReadString('\n')
fmt.Print("Jira Password: ")
bytePassword, _ := term.ReadPassword(int(syscall.Stdin))
password := string(bytePassword)
tp := jira.BasicAuthTransport{
Username: strings.TrimSpace(username),
Password: strings.TrimSpace(password),
}
client, err := jira.NewClient(tp.Client(), strings.TrimSpace(jiraURL))
if err != nil {
fmt.Printf("\nerror: %v\n", err)
return
}
u, _, err := client.User.Get("admin")
if err != nil {
fmt.Printf("\nerror: %v\n", err)
return
}
fmt.Printf("\nEmail: %v\nSuccess!\n", u.EmailAddress)
}