mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-01-05 22:53:53 +02:00
48 lines
841 B
Go
48 lines
841 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"golang.org/x/term"
|
|
"os"
|
|
"strings"
|
|
"syscall"
|
|
|
|
jira "github.com/chhekur/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)
|
|
|
|
}
|