MCPcopy Index your code
hub / github.com/git-bug/git-bug / promptTokenOptions

Function promptTokenOptions

bridge/github/config.go:321–353  ·  view source on GitHub ↗
(repo repository.RepoKeyring, login, owner, project string)

Source from the content-addressed store, hash-verified

319}
320
321func promptTokenOptions(repo repository.RepoKeyring, login, owner, project string) (auth.Credential, error) {
322 creds, err := auth.List(repo,
323 auth.WithTarget(target),
324 auth.WithKind(auth.KindToken),
325 auth.WithMeta(auth.MetaKeyLogin, login),
326 )
327 if err != nil {
328 return nil, err
329 }
330
331 cred, index, err := input.PromptCredential(target, "token", creds, []string{
332 "enter my token",
333 "interactive token creation",
334 })
335 switch {
336 case err != nil:
337 return nil, err
338 case cred != nil:
339 return cred, nil
340 case index == 0:
341 return promptToken()
342 case index == 1:
343 value, err := requestToken()
344 if err != nil {
345 return nil, err
346 }
347 token := auth.NewToken(target, value)
348 token.SetMetadata(auth.MetaKeyLogin, login)
349 return token, nil
350 default:
351 panic("missed case")
352 }
353}
354
355func promptToken() (*auth.Token, error) {
356 fmt.Println("You can generate a new token by visiting https://github.com/settings/tokens.")

Callers 1

ConfigureMethod · 0.70

Calls 9

ListFunction · 0.92
WithTargetFunction · 0.92
WithKindFunction · 0.92
WithMetaFunction · 0.92
PromptCredentialFunction · 0.92
NewTokenFunction · 0.92
requestTokenFunction · 0.85
promptTokenFunction · 0.70
SetMetadataMethod · 0.65

Tested by

no test coverage detected