mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-07 00:07:30 +08:00
cli cleanup phase4: merge config login implementation into cmd_config and remove cmd_login file
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
@@ -170,6 +171,36 @@ func configCheckCmd() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func configLoginCmd() {
|
||||||
|
cfg, err := loadConfig()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Error loading config: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Configuring CLIProxyAPI...")
|
||||||
|
fmt.Printf("Current Base: %s\n", cfg.Providers.Proxy.APIBase)
|
||||||
|
|
||||||
|
fmt.Print("Enter CLIProxyAPI Base URL (e.g. http://localhost:8080/v1): ")
|
||||||
|
reader := bufio.NewReader(os.Stdin)
|
||||||
|
line, _ := reader.ReadString('\n')
|
||||||
|
apiBase := strings.TrimSpace(line)
|
||||||
|
if apiBase != "" {
|
||||||
|
cfg.Providers.Proxy.APIBase = apiBase
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Print("Enter API Key (optional): ")
|
||||||
|
fmt.Scanln(&cfg.Providers.Proxy.APIKey)
|
||||||
|
|
||||||
|
if err := config.SaveConfig(getConfigPath(), cfg); err != nil {
|
||||||
|
fmt.Printf("Error saving config: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("✓ CLIProxyAPI configuration saved.")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func loadConfigAsMap(path string) (map[string]interface{}, error) {
|
func loadConfigAsMap(path string) (map[string]interface{}, error) {
|
||||||
return configops.LoadConfigAsMap(path)
|
return configops.LoadConfigAsMap(path)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bufio"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"clawgo/pkg/config"
|
|
||||||
)
|
|
||||||
|
|
||||||
func configLoginCmd() {
|
|
||||||
cfg, err := loadConfig()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("Error loading config: %v\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("Configuring CLIProxyAPI...")
|
|
||||||
fmt.Printf("Current Base: %s\n", cfg.Providers.Proxy.APIBase)
|
|
||||||
|
|
||||||
fmt.Print("Enter CLIProxyAPI Base URL (e.g. http://localhost:8080/v1): ")
|
|
||||||
reader := bufio.NewReader(os.Stdin)
|
|
||||||
line, _ := reader.ReadString('\n')
|
|
||||||
apiBase := strings.TrimSpace(line)
|
|
||||||
if apiBase != "" {
|
|
||||||
cfg.Providers.Proxy.APIBase = apiBase
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Print("Enter API Key (optional): ")
|
|
||||||
fmt.Scanln(&cfg.Providers.Proxy.APIKey)
|
|
||||||
|
|
||||||
if err := config.SaveConfig(getConfigPath(), cfg); err != nil {
|
|
||||||
fmt.Printf("Error saving config: %v\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("✓ CLIProxyAPI configuration saved.")
|
|
||||||
}
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user