mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
chore(docs): add and refine package-level comments across modules
- Added detailed package-level comments to improve documentation coverage. - Clarified parameter descriptions, return types, and functionality of exported methods across packages. - Enhanced overall code readability and API documentation consistency.
This commit is contained in:
@@ -12,6 +12,12 @@ import (
|
||||
)
|
||||
|
||||
// DoClaudeLogin triggers the Claude OAuth flow through the shared authentication manager.
|
||||
// It initiates the OAuth authentication process for Anthropic Claude services and saves
|
||||
// the authentication tokens to the configured auth directory.
|
||||
//
|
||||
// Parameters:
|
||||
// - cfg: The application configuration
|
||||
// - options: Login options including browser behavior and prompts
|
||||
func DoClaudeLogin(cfg *config.Config, options *LoginOptions) {
|
||||
if options == nil {
|
||||
options = &LoginOptions{}
|
||||
|
||||
@@ -4,6 +4,12 @@ import (
|
||||
sdkAuth "github.com/router-for-me/CLIProxyAPI/v6/sdk/auth"
|
||||
)
|
||||
|
||||
// newAuthManager creates a new authentication manager instance with all supported
|
||||
// authenticators and a file-based token store. It initializes authenticators for
|
||||
// Gemini, Codex, Claude, and Qwen providers.
|
||||
//
|
||||
// Returns:
|
||||
// - *sdkAuth.Manager: A configured authentication manager instance
|
||||
func newAuthManager() *sdkAuth.Manager {
|
||||
store := sdkAuth.NewFileTokenStore()
|
||||
manager := sdkAuth.NewManager(store,
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Package cmd provides command-line interface functionality for the CLI Proxy API server.
|
||||
// It includes authentication flows for various AI service providers, service startup,
|
||||
// and other command-line operations.
|
||||
package cmd
|
||||
|
||||
import (
|
||||
@@ -10,6 +13,13 @@ import (
|
||||
)
|
||||
|
||||
// DoLogin handles Google Gemini authentication using the shared authentication manager.
|
||||
// It initiates the OAuth flow for Google Gemini services and saves the authentication
|
||||
// tokens to the configured auth directory.
|
||||
//
|
||||
// Parameters:
|
||||
// - cfg: The application configuration
|
||||
// - projectID: Optional Google Cloud project ID for Gemini services
|
||||
// - options: Login options including browser behavior and prompts
|
||||
func DoLogin(cfg *config.Config, projectID string, options *LoginOptions) {
|
||||
if options == nil {
|
||||
options = &LoginOptions{}
|
||||
|
||||
@@ -12,14 +12,23 @@ import (
|
||||
)
|
||||
|
||||
// LoginOptions contains options for the login processes.
|
||||
// It provides configuration for authentication flows including browser behavior
|
||||
// and interactive prompting capabilities.
|
||||
type LoginOptions struct {
|
||||
// NoBrowser indicates whether to skip opening the browser automatically.
|
||||
NoBrowser bool
|
||||
|
||||
// Prompt allows the caller to provide interactive input when needed.
|
||||
Prompt func(prompt string) (string, error)
|
||||
}
|
||||
|
||||
// DoCodexLogin triggers the Codex OAuth flow through the shared authentication manager.
|
||||
// It initiates the OAuth authentication process for OpenAI Codex services and saves
|
||||
// the authentication tokens to the configured auth directory.
|
||||
//
|
||||
// Parameters:
|
||||
// - cfg: The application configuration
|
||||
// - options: Login options including browser behavior and prompts
|
||||
func DoCodexLogin(cfg *config.Config, options *LoginOptions) {
|
||||
if options == nil {
|
||||
options = &LoginOptions{}
|
||||
|
||||
@@ -11,6 +11,12 @@ import (
|
||||
)
|
||||
|
||||
// DoQwenLogin handles the Qwen device flow using the shared authentication manager.
|
||||
// It initiates the device-based authentication process for Qwen services and saves
|
||||
// the authentication tokens to the configured auth directory.
|
||||
//
|
||||
// Parameters:
|
||||
// - cfg: The application configuration
|
||||
// - options: Login options including browser behavior and prompts
|
||||
func DoQwenLogin(cfg *config.Config, options *LoginOptions) {
|
||||
if options == nil {
|
||||
options = &LoginOptions{}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Package cmd provides command-line interface functionality for the CLI Proxy API server.
|
||||
// It includes authentication flows for various AI service providers, service startup,
|
||||
// and other command-line operations.
|
||||
package cmd
|
||||
|
||||
import (
|
||||
@@ -12,6 +15,12 @@ import (
|
||||
)
|
||||
|
||||
// StartService builds and runs the proxy service using the exported SDK.
|
||||
// It creates a new proxy service instance, sets up signal handling for graceful shutdown,
|
||||
// and starts the service with the provided configuration.
|
||||
//
|
||||
// Parameters:
|
||||
// - cfg: The application configuration
|
||||
// - configPath: The path to the configuration file
|
||||
func StartService(cfg *config.Config, configPath string) {
|
||||
service, err := cliproxy.NewBuilder().
|
||||
WithConfig(cfg).
|
||||
|
||||
Reference in New Issue
Block a user