From 7b0fbb6fef5bde60eae8be0c354d3d9c5e622d71 Mon Sep 17 00:00:00 2001 From: Daniel Barczyk <46358936+DanielBarczyk@users.noreply.github.com> Date: Sun, 30 Jan 2022 08:09:37 +0100 Subject: [PATCH] cmd/syncthing/cli: Add showing pending folders for given device (fixes #8130) (#8131) Add --device flag to filter pending folders. --- cmd/syncthing/cli/pending.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/cmd/syncthing/cli/pending.go b/cmd/syncthing/cli/pending.go index 362ba1a59..315ff731c 100644 --- a/cmd/syncthing/cli/pending.go +++ b/cmd/syncthing/cli/pending.go @@ -7,6 +7,8 @@ package cli import ( + "net/url" + "github.com/urfave/cli" ) @@ -21,9 +23,23 @@ var pendingCommand = cli.Command{ Action: expects(0, indexDumpOutput("cluster/pending/devices")), }, { - Name: "folders", - Usage: "Show pending folders", - Action: expects(0, indexDumpOutput("cluster/pending/folders")), + Name: "folders", + Usage: "Show pending folders", + Flags: []cli.Flag{ + cli.StringFlag{Name: "device", Usage: "Show pending folders offered by given device"}, + }, + Action: expects(0, folders()), }, }, } + +func folders() cli.ActionFunc { + return func(c *cli.Context) error { + if c.String("device") != "" { + query := make(url.Values) + query.Set("device", c.String("device")) + return indexDumpOutput("cluster/pending/folders?" + query.Encode())(c) + } + return indexDumpOutput("cluster/pending/folders")(c) + } +}