From 1555a4da7ff6c35a583551ede9d2c79cb6563cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Colomb?= Date: Tue, 22 Dec 2020 22:10:26 +0100 Subject: [PATCH] cmd/stevents: Add command line argument for event type filtering. (#7226) Add a -types flag which can be set to a comma-separated list of event types. The contents will be included verbatim in the URL parameter "events". --- cmd/stevents/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/stevents/main.go b/cmd/stevents/main.go index f1b171cdd..b723ab542 100644 --- a/cmd/stevents/main.go +++ b/cmd/stevents/main.go @@ -28,16 +28,21 @@ func main() { log.SetFlags(0) target := flag.String("target", "localhost:8384", "Target Syncthing instance") + types := flag.String("types", "", "Filter for specific event types (comma-separated)") apikey := flag.String("apikey", "", "Syncthing API key") flag.Parse() if *apikey == "" { log.Fatal("Must give -apikey argument") } + var eventsArg string + if len(*types) > 0 { + eventsArg = "&events=" + *types + } since := 0 for { - req, err := http.NewRequest("GET", fmt.Sprintf("http://%s/rest/events?since=%d", *target, since), nil) + req, err := http.NewRequest("GET", fmt.Sprintf("http://%s/rest/events?since=%d%s", *target, since, eventsArg), nil) if err != nil { log.Fatal(err) }