mirror of
https://github.com/githubhjs/CLIProxyAPIPlus.git
synced 2026-07-13 18:15:24 +00:00
refactor: extract setKiroIncognitoMode helper to reduce code duplication
- Added setKiroIncognitoMode() helper function to handle Kiro auth incognito mode setting - Replaced 3 duplicate code blocks (21 lines) with single function calls (3 lines) - Kiro auth defaults to incognito mode for multi-account support - Users can override with --incognito or --no-incognito flags This addresses the code duplication noted in PR #1 review.
This commit is contained in:
+16
-21
@@ -47,6 +47,19 @@ func init() {
|
|||||||
buildinfo.BuildDate = BuildDate
|
buildinfo.BuildDate = BuildDate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setKiroIncognitoMode sets the incognito browser mode for Kiro authentication.
|
||||||
|
// Kiro defaults to incognito mode for multi-account support.
|
||||||
|
// Users can explicitly override with --incognito or --no-incognito flags.
|
||||||
|
func setKiroIncognitoMode(cfg *config.Config, useIncognito, noIncognito bool) {
|
||||||
|
if useIncognito {
|
||||||
|
cfg.IncognitoBrowser = true
|
||||||
|
} else if noIncognito {
|
||||||
|
cfg.IncognitoBrowser = false
|
||||||
|
} else {
|
||||||
|
cfg.IncognitoBrowser = true // Kiro default
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// main is the entry point of the application.
|
// main is the entry point of the application.
|
||||||
// It parses command-line flags, loads configuration, and starts the appropriate
|
// It parses command-line flags, loads configuration, and starts the appropriate
|
||||||
// service based on the provided flags (login, codex-login, or server mode).
|
// service based on the provided flags (login, codex-login, or server mode).
|
||||||
@@ -465,36 +478,18 @@ func main() {
|
|||||||
// Users can explicitly override with --no-incognito
|
// Users can explicitly override with --no-incognito
|
||||||
// Note: This config mutation is safe - auth commands exit after completion
|
// Note: This config mutation is safe - auth commands exit after completion
|
||||||
// and don't share config with StartService (which is in the else branch)
|
// and don't share config with StartService (which is in the else branch)
|
||||||
if useIncognito {
|
setKiroIncognitoMode(cfg, useIncognito, noIncognito)
|
||||||
cfg.IncognitoBrowser = true
|
|
||||||
} else if noIncognito {
|
|
||||||
cfg.IncognitoBrowser = false
|
|
||||||
} else {
|
|
||||||
cfg.IncognitoBrowser = true // Kiro default
|
|
||||||
}
|
|
||||||
cmd.DoKiroLogin(cfg, options)
|
cmd.DoKiroLogin(cfg, options)
|
||||||
} else if kiroGoogleLogin {
|
} else if kiroGoogleLogin {
|
||||||
// For Kiro auth, default to incognito mode for multi-account support
|
// For Kiro auth, default to incognito mode for multi-account support
|
||||||
// Users can explicitly override with --no-incognito
|
// Users can explicitly override with --no-incognito
|
||||||
// Note: This config mutation is safe - auth commands exit after completion
|
// Note: This config mutation is safe - auth commands exit after completion
|
||||||
if useIncognito {
|
setKiroIncognitoMode(cfg, useIncognito, noIncognito)
|
||||||
cfg.IncognitoBrowser = true
|
|
||||||
} else if noIncognito {
|
|
||||||
cfg.IncognitoBrowser = false
|
|
||||||
} else {
|
|
||||||
cfg.IncognitoBrowser = true // Kiro default
|
|
||||||
}
|
|
||||||
cmd.DoKiroGoogleLogin(cfg, options)
|
cmd.DoKiroGoogleLogin(cfg, options)
|
||||||
} else if kiroAWSLogin {
|
} else if kiroAWSLogin {
|
||||||
// For Kiro auth, default to incognito mode for multi-account support
|
// For Kiro auth, default to incognito mode for multi-account support
|
||||||
// Users can explicitly override with --no-incognito
|
// Users can explicitly override with --no-incognito
|
||||||
if useIncognito {
|
setKiroIncognitoMode(cfg, useIncognito, noIncognito)
|
||||||
cfg.IncognitoBrowser = true
|
|
||||||
} else if noIncognito {
|
|
||||||
cfg.IncognitoBrowser = false
|
|
||||||
} else {
|
|
||||||
cfg.IncognitoBrowser = true // Kiro default
|
|
||||||
}
|
|
||||||
cmd.DoKiroAWSLogin(cfg, options)
|
cmd.DoKiroAWSLogin(cfg, options)
|
||||||
} else if kiroImport {
|
} else if kiroImport {
|
||||||
cmd.DoKiroImport(cfg, options)
|
cmd.DoKiroImport(cfg, options)
|
||||||
|
|||||||
Reference in New Issue
Block a user