diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 84f1482..c17acd6 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" "os" "time" @@ -211,6 +212,11 @@ func fetchServices() tea.Msg { } func main() { + serverURL := flag.String("server", "http://localhost:8080", "URL of the EnvGuard server") + flag.Parse() + + api.SetBaseURL(*serverURL) + user := os.Getenv("USER") if user == "" { user = "guest" diff --git a/internal/api/client.go b/internal/api/client.go index db99a09..3bf2b4f 100644 --- a/internal/api/client.go +++ b/internal/api/client.go @@ -10,7 +10,11 @@ import ( "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}