Unified · Split
| @@ -58,14 +58,19 @@ func DoLogin(cfg *config.Config, projectID string, options *LoginOptions) { · 57 unmodified lines | |||
| 58 | promptFn := options.Prompt | 58 | promptFn := options.Prompt |
| 59 | if promptFn == nil { | 59 | if promptFn == nil { |
| 60 | promptFn = defaultProjectPrompt() | 60 | promptFn = defaultProjectPrompt() |
| 61 | options.Prompt = promptFn | 61 | } |
| 62 | |||
| 63 | trimmedProjectID := strings.TrimSpace(projectID) | ||
| 64 | callbackPrompt := promptFn | ||
| 65 | if trimmedProjectID == "" { | ||
| 66 | callbackPrompt = nil | ||
| 62 | } | 67 | } |
| 63 | 68 | ||
| 64 | loginOpts := &sdkAuth.LoginOptions{ | 69 | loginOpts := &sdkAuth.LoginOptions{ |
| 65 | NoBrowser: options.NoBrowser, | 70 | NoBrowser: options.NoBrowser, |
| 66 | ProjectID: strings.TrimSpace(projectID), | 71 | ProjectID: trimmedProjectID, |
| 67 | Metadata: map[string]string{}, | 72 | Metadata: map[string]string{}, |
| 68 | Prompt: promptFn, | 73 | Prompt: callbackPrompt, |
| 69 | } | 74 | } |
| 70 | 75 | ||
| 71 | authenticator := sdkAuth.NewGeminiAuthenticator() | 76 | authenticator := sdkAuth.NewGeminiAuthenticator() |
| @@ -84,7 +89,7 @@ func DoLogin(cfg *config.Config, projectID string, options *LoginOptions) { · 12 unmodified lines | |||
| 84 | geminiAuth := gemini.NewGeminiAuth() | 89 | geminiAuth := gemini.NewGeminiAuth() |
| 85 | httpClient, errClient := geminiAuth.GetAuthenticatedClient(ctx, storage, cfg, &gemini.WebLoginOptions{ | 90 | httpClient, errClient := geminiAuth.GetAuthenticatedClient(ctx, storage, cfg, &gemini.WebLoginOptions{ |
| 86 | NoBrowser: options.NoBrowser, | 91 | NoBrowser: options.NoBrowser, |
| 87 | Prompt: promptFn, | 92 | Prompt: callbackPrompt, |
| 88 | }) | 93 | }) |
| 89 | if errClient != nil { | 94 | if errClient != nil { |
| 90 | log.Errorf("Gemini authentication failed: %v", errClient) | 95 | log.Errorf("Gemini authentication failed: %v", errClient) |
| @@ -99,7 +104,7 @@ func DoLogin(cfg *config.Config, projectID string, options *LoginOptions) { · 8 unmodified lines | |||
| 99 | return | 104 | return |
| 100 | } | 105 | } |
| 101 | 106 | ||
| 102 | selectedProjectID := promptForProjectSelection(projects, strings.TrimSpace(projectID), promptFn) | 107 | selectedProjectID := promptForProjectSelection(projects, trimmedProjectID, promptFn) |
| 103 | projectSelections, errSelection := resolveProjectSelections(selectedProjectID, projects) | 108 | projectSelections, errSelection := resolveProjectSelections(selectedProjectID, projects) |
| 104 | if errSelection != nil { | 109 | if errSelection != nil { |
| 105 | log.Errorf("Invalid project selection: %v", errSelection) | 110 | log.Errorf("Invalid project selection: %v", errSelection) |