feat: add 'dump' command to print payload JSON without sending

This commit is contained in:
Joel Male
2026-02-25 15:09:45 +10:00
parent f4e5bafa73
commit 342b105df9
+26
View File
@@ -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 {