Repository: syncthing/syncthing (language: go)

Issue:
CLI: add command to print pending folders offered by specific device
The syncthing CLI allows to show pending devices and folders with the commands:
```
syncthing cli show pending devices
syncthing cli show pending folders
```
respectively. From the API [GET /rest/cluster/pending/folders](https://docs.syncthing.net/rest/cluster-pending-folders-get.html):

> Lists folders which remote devices have offered to us, but are not yet shared from our instance to them. Takes the optional device parameter to only return folders offered by a specific remote device. Other offering devices are also omitted from the result.

Therefore I think it would be good to sync the CLI with the API and add a command that takes a deviceId parameter and prints pending folders offered by that specific device.


Discussion / hints:

Fix patch:
diff --git a/cmd/syncthing/cli/pending.go b/cmd/syncthing/cli/pending.go
index 362ba1a5974..315ff731c7f 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)
+	}
+}


Test patch: