cmd/syncthing/cli: Add showing pending folders for given device (fixes #8130) (#8131)

Add --device flag to filter pending folders.
This commit is contained in:
Daniel Barczyk 2022-01-30 08:09:37 +01:00 committed by GitHub
parent 80d4bc1cea
commit 7b0fbb6fef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,8 @@
package cli
import (
"net/url"
"github.com/urfave/cli"
)
@ -23,7 +25,21 @@ var pendingCommand = cli.Command{
{
Name: "folders",
Usage: "Show pending folders",
Action: expects(0, indexDumpOutput("cluster/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)
}
}