From 342b105df96d5ddae466391354bcf47564bc6023 Mon Sep 17 00:00:00 2001 From: Joel Male Date: Wed, 25 Feb 2026 15:09:45 +1000 Subject: [PATCH] feat: add 'dump' command to print payload JSON without sending --- main.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/main.go b/main.go index 2db7938..f2f00ed 100644 --- a/main.go +++ b/main.go @@ -184,6 +184,9 @@ func main() { case "uninstall": runUninstallCommand() return + case "dump": + runDumpCommand() + return } } @@ -277,6 +280,29 @@ func runUpdateCommand() { fmt.Printf(" Successfully updated to %sv%s%s.\n\n", ansiCyan, latest, ansiReset) } +func runDumpCommand() { + if os.Getuid() != 0 { + reexecWithSudo() + return + } + + config := loadConfig() + + metrics, err := collectMetrics(config) + if err != nil { + fmt.Fprintf(os.Stderr, "%sError collecting metrics: %v%s\n", ansiRed, err, ansiReset) + os.Exit(1) + } + + out, err := json.MarshalIndent(metrics, "", " ") + if err != nil { + fmt.Fprintf(os.Stderr, "%sError marshalling metrics: %v%s\n", ansiRed, err, ansiReset) + os.Exit(1) + } + + fmt.Println(string(out)) +} + func reexecWithSudo() { self, err := os.Executable() if err != nil {