feat: add server url parameter to cli

This commit is contained in:
Jose Luis Montañes Ojados
2026-01-28 15:20:53 +01:00
parent cb704c1b1f
commit a857c1a051
2 changed files with 11 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
package main package main
import ( import (
"flag"
"fmt" "fmt"
"os" "os"
"time" "time"
@@ -211,6 +212,11 @@ func fetchServices() tea.Msg {
} }
func main() { func main() {
serverURL := flag.String("server", "http://localhost:8080", "URL of the EnvGuard server")
flag.Parse()
api.SetBaseURL(*serverURL)
user := os.Getenv("USER") user := os.Getenv("USER")
if user == "" { if user == "" {
user = "guest" user = "guest"

View File

@@ -10,7 +10,11 @@ import (
"envguard/internal/models" "envguard/internal/models"
) )
const baseURL = "http://localhost:8080" var baseURL = "http://localhost:8080"
func SetBaseURL(url string) {
baseURL = url
}
var client = &http.Client{Timeout: 5 * time.Second} var client = &http.Client{Timeout: 5 * time.Second}