From 2d126e62939ef26ed165540a2aa4259dbbaa7f83 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Mon, 16 Sep 2024 14:23:04 +0200 Subject: [PATCH] add config detection to debug command --- proxy/debug.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/proxy/debug.go b/proxy/debug.go index 90fe8ec..9db4400 100644 --- a/proxy/debug.go +++ b/proxy/debug.go @@ -1,7 +1,10 @@ package proxy import ( + "errors" "fmt" + "os" + "path/filepath" "strings" "github.com/Baipyrus/ProxySwitcher/util" @@ -20,13 +23,21 @@ func mapCmdsToStr(commands []*util.Command) string { } func Debug(cfgFile string) { + path, _ := filepath.Abs(cfgFile) + if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) { + path = "[N/A]" + } + + fmt.Printf("\nConfig:\n") + fmt.Printf("%s\n\n", path) + proxy, _ := ReadSystemProxy() proxyServer := proxy.Server if proxyServer == "" { proxyServer = "[N/A]" } - fmt.Println("\nSystem Proxy:") + fmt.Println("System Proxy:") fmt.Printf("Enabled: %t\n", proxy.Enabled) fmt.Printf("Server: %s\n\n", proxyServer)