func pr(label string, confirm bool) string { if !confirm { return prompt.Secure("%s: ", label) } for { a := prompt.Secure("%s @Y{[hidden]:} ", label) b := prompt.Secure("%s @C{[confirm]:} ", label) if a == b && a != "" { ansi.Fprintf(os.Stderr, "\n") return a } ansi.Fprintf(os.Stderr, "\n@Y{oops, try again }(Ctrl-C to cancel)\n\n") } }
func Github(addr string) (string, error) { access := prompt.Secure("Github Personal Access Token: ") body := struct { Token string `json:"token"` }{access} b, err := json.Marshal(body) if err != nil { return "", err } req, err := http.NewRequest("POST", authurl(addr, "/v1/auth/github/login"), strings.NewReader(string(b))) if err != nil { return "", err } return authenticate(req) }
func Token(addr string) (string, error) { return prompt.Secure("Token: "), nil }