main is the entry point of the application. It parses command-line flags, loads configuration, and starts the appropriate service based on the provided flags (login, codex-login, or server mode).
()
| 68 | // It parses command-line flags, loads configuration, and starts the appropriate |
| 69 | // service based on the provided flags (login, codex-login, or server mode). |
| 70 | func main() { |
| 71 | fmt.Printf("CLIProxyAPI Version: %s, Commit: %s, BuiltAt: %s\n", buildinfo.Version, buildinfo.Commit, buildinfo.BuildDate) |
| 72 | |
| 73 | // Command-line flags to control the application's behavior. |
| 74 | var codexLogin bool |
| 75 | var codexDeviceLogin bool |
| 76 | var claudeLogin bool |
| 77 | var noBrowser bool |
| 78 | var oauthCallbackPort int |
| 79 | var antigravityLogin bool |
| 80 | var kimiLogin bool |
| 81 | var xaiLogin bool |
| 82 | var vertexImport string |
| 83 | var vertexImportPrefix string |
| 84 | var configPath string |
| 85 | var password string |
| 86 | var homeJWT string |
| 87 | var homeDisableClusterDiscovery bool |
| 88 | var tuiMode bool |
| 89 | var standalone bool |
| 90 | var localModel bool |
| 91 | |
| 92 | // Define command-line flags for different operation modes. |
| 93 | flag.BoolVar(&codexLogin, "codex-login", false, "Login to Codex using OAuth") |
| 94 | flag.BoolVar(&codexDeviceLogin, "codex-device-login", false, "Login to Codex using device code flow") |
| 95 | flag.BoolVar(&claudeLogin, "claude-login", false, "Login to Claude using OAuth") |
| 96 | flag.BoolVar(&noBrowser, "no-browser", false, "Don't open browser automatically for OAuth") |
| 97 | flag.IntVar(&oauthCallbackPort, "oauth-callback-port", 0, "Override OAuth callback port (defaults to provider-specific port)") |
| 98 | flag.BoolVar(&antigravityLogin, "antigravity-login", false, "Login to Antigravity using OAuth") |
| 99 | flag.BoolVar(&kimiLogin, "kimi-login", false, "Login to Kimi using OAuth") |
| 100 | flag.BoolVar(&xaiLogin, "xai-login", false, "Login to xAI using OAuth") |
| 101 | flag.StringVar(&configPath, "config", DefaultConfigPath, "Configure File Path") |
| 102 | flag.StringVar(&vertexImport, "vertex-import", "", "Import Vertex service account key JSON file") |
| 103 | flag.StringVar(&vertexImportPrefix, "vertex-import-prefix", "", "Prefix for Vertex model namespacing (use with -vertex-import)") |
| 104 | flag.StringVar(&password, "password", "", "") |
| 105 | flag.StringVar(&homeJWT, "home-jwt", "", "Home control plane JWT for mTLS certificate bootstrap and connection") |
| 106 | flag.BoolVar(&homeDisableClusterDiscovery, "home-disable-cluster-discovery", false, "Disable Home CLUSTER NODES discovery and keep using the configured -home-jwt address") |
| 107 | flag.BoolVar(&tuiMode, "tui", false, "Start with terminal management UI") |
| 108 | flag.BoolVar(&standalone, "standalone", false, "In TUI mode, start an embedded local server") |
| 109 | flag.BoolVar(&localModel, "local-model", false, "Use embedded model catalog only, skip remote model fetching") |
| 110 | |
| 111 | flag.CommandLine.Usage = func() { |
| 112 | out := flag.CommandLine.Output() |
| 113 | _, _ = fmt.Fprintf(out, "Usage of %s\n", os.Args[0]) |
| 114 | flag.CommandLine.VisitAll(func(f *flag.Flag) { |
| 115 | if f.Name == "password" { |
| 116 | return |
| 117 | } |
| 118 | s := fmt.Sprintf(" -%s", f.Name) |
| 119 | name, unquoteUsage := flag.UnquoteUsage(f) |
| 120 | if name != "" { |
| 121 | s += " " + name |
| 122 | } |
| 123 | if len(s) <= 4 { |
| 124 | s += " " |
| 125 | } else { |
| 126 | s += "\n " |
| 127 | } |
nothing calls this directly
no test coverage detected