mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-19 19:45:12 +00:00
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".
This commit is contained in:
parent
a20a5f61f0
commit
1555a4da7f
@ -28,16 +28,21 @@ func main() {
|
|||||||
log.SetFlags(0)
|
log.SetFlags(0)
|
||||||
|
|
||||||
target := flag.String("target", "localhost:8384", "Target Syncthing instance")
|
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")
|
apikey := flag.String("apikey", "", "Syncthing API key")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *apikey == "" {
|
if *apikey == "" {
|
||||||
log.Fatal("Must give -apikey argument")
|
log.Fatal("Must give -apikey argument")
|
||||||
}
|
}
|
||||||
|
var eventsArg string
|
||||||
|
if len(*types) > 0 {
|
||||||
|
eventsArg = "&events=" + *types
|
||||||
|
}
|
||||||
|
|
||||||
since := 0
|
since := 0
|
||||||
for {
|
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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user